Skip to main content

Questions tagged [github-actions]

GitHub Actions allows you to easily automate your software workflows. Use this tag for questions regarding help on creating a workflow. If you need help on GitHub Actions in general, consider contacting GitHub by emailing their support (support.github.com/contact) or by asking in GitHub's Community Forum (github.com/orgs/community/discussions.

Filter by
Sorted by
Tagged with
384 votes
36 answers
386k views

How to get the current branch within Github Actions?

I'm building Docker images with Github Actions and want to tag images with the branch name. I found the GITHUB_REF variable, but it results in refs/heads/feature-branch-1 and I need only feature-...
aborilov's user avatar
  • 8,304
354 votes
9 answers
228k views

How to run a github-actions step, even if the previous step fails, while still failing the job

I'm trying to follow an example Github has for testing my build with github actions, and then compressing the test results and uploading them as an artifact. https://help.github.com/en/actions/...
Tomer Shemesh's user avatar
343 votes
4 answers
310k views

Running actions in another directory

I've just started exploring Github actions however I've found myself placing a command in multiple places. I have a PHP project where the composer.json is not in the root, my structure looks like: ...
MylesK's user avatar
  • 4,089
314 votes
3 answers
121k views

How to apt-get install in a GitHub Actions workflow?

In the new GitHub Actions, I am trying to install a package in order to use it in one of the next steps. name: CI on: [push, pull_request] jobs: translations: runs-on: ubuntu-latest steps: ...
Niklas's user avatar
  • 4,093
279 votes
10 answers
218k views

How can I run GitHub Actions workflows locally?

I am planning to move our Travis CI build to GitHub Actions using Docker for our per-commit testing. Can I reproducibly run these new GitHub Actions workflows locally? Is there a generic way to run ...
William Entriken's user avatar
268 votes
3 answers
238k views

How do I set an env var with a bash expression in GitHub Actions?

In GitHub Actions, I'd like to evaluate a bash expression and then assign it to an environment variable: - name: Tag image env: GITHUB_SHA_SHORT: ${{ $(echo $GITHUB_SHA | cut -c 1-6)...
evilSnobu's user avatar
  • 25.7k
265 votes
12 answers
230k views

Only run job on specific branch with GitHub Actions

I'm relatively new to GitHub Actions and I have 2 jobs–one that runs my tests, and one that deploys my project onto a server. Obviously I want the tests to run on every branch, but deploying should ...
weakdan's user avatar
  • 2,926
228 votes
23 answers
110k views

How to resolve "refusing to allow an OAuth App to create or update workflow" on git push

Getting refusing to allow an OAuth App to create or update workflow .github/workflows/cd.yml without workflow scope" on git push. How to grant workflow scope?
Ara Yeressian's user avatar
223 votes
5 answers
107k views

Dependencies Between Workflows on Github Actions

I have a monorepo with two workflows: .github/workflows/test.yml name: test on: [push, pull_request] jobs: test-packages: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 ...
Guillaume Vincent's user avatar
219 votes
7 answers
121k views

Github Action: Split Long Command into Multiple Lines

I have a Github action command that is really long: name: build on: [push] jobs: build: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v1 - name: ...
Bojian Zheng's user avatar
  • 2,647
210 votes
6 answers
113k views

Github actions share workspace/artifacts between jobs?

Trying to use Github's beta actions, I have two jobs, one that builds the code and then one that will deploy code. However, I can't seem to get the build artifact in deploy job. My latest attempt is ...
Labithiotis's user avatar
  • 3,919
177 votes
33 answers
82k views

Delete a workflow from GitHub Actions

I created a couple workflows in the .github/workflows folder of my repository to experiment with GitHub Actions. I have since learned quite a bit and deleted said experimental workflows from my repo. ...
skålfyfan's user avatar
  • 5,181
154 votes
5 answers
119k views

How to run GitHub Actions workflow only if the pushed files are in a specific folder

I have a folder structure that looks something like this. - folder1 - file1 - *other files* - folder2 - file1 - *other files* - .gitignore - package.json - *other files* I want to run my ...
TheComputerM's user avatar
  • 1,721
151 votes
8 answers
114k views

Get the current pushed tag in Github Actions

Is there a way to access the current tag that has been pushed in a Github Action? In CircleCI you can access this value with the $CIRCLE_TAG variable. My Workflow yaml is being triggered by a tag like ...
Jon B's user avatar
  • 2,744
146 votes
4 answers
120k views

In a github actions workflow, is there a way to have multiple jobs reuse the same setup?

I recently hooked up my project with github actions for continuous integration. I created two separate jobs: the first one checks if the code in the pull request is accepted by our linter, and the ...
hugomg's user avatar
  • 69.5k
145 votes
5 answers
128k views

Github Actions - trigger another action after one action is completed

I have one action (a yaml file) for deploying a docker image to Google Cloud Run. I would like to receive Slack or Email messages informing the build and push results. How could the message action be ...
CSSer's user avatar
  • 2,497
145 votes
1 answer
81k views

Set default Timeout on Github action pipeline

Normally, my pipelines take 15 minutes to execute. Recently, for some strange reasons, some pipelines take between 45 minutes and 6 hours to fail. Is it possible to set a default timeout limit on ...
Kevin ABRIOUX's user avatar
144 votes
3 answers
107k views

Repository 'http://security.debian.org/debian-security buster/updates InRelease' changed its 'Suite' value from 'stable' to 'oldstable'

Some of my GitHub Actions workflows started recently to return this error when installing Chromedriver: Get:1 http://security.debian.org/debian-security buster/updates InRelease [65.4 kB] Get:2 http://...
GuiFalourd's user avatar
141 votes
7 answers
110k views

GitHub Actions: how can I run a workflow created on a non-'master' branch from the 'workflow_dispatch' event?

For actions working on a third party repository, I would like to be able to create an action on a branch and execute it on the workflow_dispatch event. I have not succeeded in doing this, but I have ...
mikemay's user avatar
  • 4,317
133 votes
29 answers
158k views

GitHub Action workflow not running

I have a GitHub action workflow file @ myrepo/.github/workflows/Build Webpage.yml it contains this: name: Webpage Build on: push: branches: - webpage jobs: build: runs-on: ...
KieranLewin's user avatar
  • 2,080
131 votes
2 answers
92k views

GitHub Actions: how to target all branches EXCEPT master?

I want to be able to let an action run on any given branch except master. I am aware that there is a prebuilt filter action, but I want the exact opposite. More like GitLab's except keyword. Since ...
fweidemann14's user avatar
  • 1,914
130 votes
7 answers
141k views

Using output from a previous job in a new one in a GitHub Action

For (mainly) pedagogical reasons, I'm trying to run this workflow in GitHub actions: name: "We 🎔 Perl" on: issues: types: [opened, edited, milestoned] jobs: seasonal_greetings: runs-on: ...
jjmerelo's user avatar
  • 23.2k
130 votes
10 answers
98k views

Clear cache in GitHub Actions

I am working on an R package and using GitHub Action (GHA) as a Continuous Integration (CI) provider. I cache R packages (dependencies) by using actions/cache. And now I want to clear all cache. How ...
GegznaV's user avatar
  • 5,370
129 votes
1 answer
122k views

How to run multiple commands in one Github Actions Docker

What is the right way for running multiple commands in one action? For example: I want to run a python script as action. Before running this script I need to install the requirements.txt. I can ...
baruchiro's user avatar
  • 5,618
128 votes
16 answers
140k views

How do I use an env file with GitHub Actions?

I have multiple environments (dev, qa, prod) and I'm using .env files to store secrets etc... Now I'm switching to GitHub Actions, and I want to use my .env files and declare them into the env section ...
HRK44's user avatar
  • 2,632
128 votes
6 answers
145k views

"Resource not accessible by integration" on github post /repos/{owner}/{repo}/actions/runners/registration-token API

I am making a curl post request from my github workflow (action) to get registration token for a self-hosted runner but I am receiving the following response: { "message": "Resource ...
nu_popli's user avatar
  • 1,660
128 votes
2 answers
31k views

GitHub Actions: Run step on specific OS

I'm using GitHub Actions to run a workflow on multiple operating systems. However, there is a specific step that I have to run only on Ubuntu: runs-on: ${{ matrix.os }} strategy: matrix: ...
yahavi's user avatar
  • 5,713
118 votes
4 answers
69k views

Reuse portion of github action across jobs

I have a workflow for CI in a monorepo, for this workflow two projects end up being built. The jobs run fine, however, I'm wondering if there is a way to remove the duplication in this workflow.yml ...
Brad Martin's user avatar
  • 6,007
117 votes
8 answers
158k views

Getting current branch and commit hash in GitHub action

I want to build a docker image using a GitHub action, migrating from TeamCity. In the build script, I want to tag the image with a combination of branch and commit, e.g. master.ad959de. Testing that ...
Rüdiger Schulz's user avatar
114 votes
5 answers
185k views

How do I get the output of a specific step in GitHub Actions?

I have this GitHub Actions workflow which runs tests, but now I am integrating slack notification in it. I want to get the output of the Run tests step and send it as a message in the slack step. - ...
script's user avatar
  • 1,987
113 votes
8 answers
122k views

Trigger Github Actions only when PR is merged

I have a github actions yaml file as follows: name: Test deployment on: pull_request: branches: - master jobs: deploy: runs-on: ubuntu-18.04 steps: - name: Random name ...
Srikanth Sharma's user avatar
108 votes
3 answers
89k views

Trigger Github Action only on new tags?

Is there a possibility to trigger a GitHub action only if a new version (which comes with a new tag) is pushed? I don't want run them on every push into master, but I also want to avoid creating a ...
mrvnklm's user avatar
  • 1,698
105 votes
6 answers
110k views

Push to origin from GitHub action

I'm trying to push to origin remote from GitHub action. The logic of my action is: handle pull_request_review events and filter by comment message checkout to master, merge PR branch, run some checks ...
Kirill's user avatar
  • 8,031
104 votes
2 answers
84k views

How do I use Docker with GitHub Actions?

When I create a GitHub Actions workflow file, the example YAML file contains runs-on: ubuntu-latest. According to the docs, I only have the options between a couple versions of Ubuntu, Windows Server ...
soerface's user avatar
  • 6,695
103 votes
5 answers
33k views

How to cancel previous runs in the PR when you push new commits(update the current) in github-actions

When I push my commits to a PR my tests are triggered for this commit. After that, if I push additional commits to this PR, tests in Github Actions runs on both commits. I need to cancel the previous ...
Max's user avatar
  • 1,175
103 votes
5 answers
153k views

How can I run a GitHub Action from a branch other than 'master'?

I have a repository in GitHub and I want to create an Action to build a Docker image and push it to the Docker Hub. I know how to do it, but if I create the action in a branch other than master, ...
E. Betanzos's user avatar
  • 1,720
100 votes
3 answers
30k views

Difference between Github's "Environment" and "Repository" secrets?

In the GitHub documentation it states that the precedence of secrets is from lowest to highest (Environment > Repository > Organization), it also states that the Organization secrets are ...
Adam's user avatar
  • 1,345
98 votes
3 answers
82k views

How to fail a job in Github Actions?

I'm developing a Github actions workflow. This workflow runs on Linux, Mac, and Windows. As part of the workflow, I have to check whether 2 environment variables are equal. If they don't - fail the ...
yahavi's user avatar
  • 5,713
98 votes
2 answers
96k views

Create dependencies between jobs in GitHub Actions

I'm new to GitHub Actions, playing with various options to work out good approaches to CI/CD pipelines. Initially I had all my CI steps under one job, doing the following: checkout code from repo ...
JohnLBevan's user avatar
  • 23.9k
97 votes
6 answers
88k views

Get current date and time in GitHub workflows

I have a GitHub workflow for releasing nightly snapshots of the repository. It uses the create-release action. This is how the workflow file looks right now: name: Release Nightly Snapshot on: ...
Wowbagger and his liquid lunch's user avatar
97 votes
3 answers
82k views

Github Actions, how to share a calculated value between job steps?

Is there a DRY way to calculate and share a value in multiple job steps with Github Actions? In the below workflow yml file, echo ${GITHUB_REF} | cut -d'/' -f3`-${GITHUB_SHA} is repeated in multiple ...
Casey Flynn's user avatar
  • 13.9k
95 votes
10 answers
80k views

The unauthenticated git protocol on port 9418 is no longer supported

I have been using github actions for quite sometime but today my deployments started failing. Below is the error from github action logs Command: git Arguments: ls-remote --tags --heads git://github....
monofal's user avatar
  • 1,968
92 votes
10 answers
59k views

Cloning private github repository within organisation in actions

I have 2 private GitHub repositories (say A and B) in the organization (say ORG). Repository A has repository B in requirements.txt: -e [email protected]:ORG/B.git#egg=B And I have the following ...
Yevhen Kuzmovych's user avatar
90 votes
21 answers
155k views

npm ci can only install packages with an existing package-lock.json or npm-shrinkwrap.json with lockfileVersion >= 1

This is the issue that I am facing when running the command npm ci to install dependencies in my GitHub Action file. I am working on an expo managed app and using GitHub Actions as a CI for triggering ...
sakshya73's user avatar
  • 6,774
89 votes
3 answers
33k views

Trigger a GitHub Action when another repository creates a new release

I'm trying to build a GitHub workflow that will be triggered when another repository creates a new release. In the documentation, there is the paragraph: on.event_name.types where event_name will be ...
pierDipi's user avatar
  • 1,470
87 votes
6 answers
67k views

How do I cache steps in GitHub actions?

Say I have a GitHub actions workflow with 2 steps. Download and compile my application's dependencies. Compile and test my application My dependencies rarely change and the compiled dependencies can ...
lpil's user avatar
  • 1,797
86 votes
2 answers
41k views

GitHub Actions - How to build project in sub-directory

I'm using GitHub Actions to build my project but my Dart project is in a sub-directory in the repository. The Action script can't find my pubspec.yaml and get the dependencies. How can I point my ...
Evandro Pomatti's user avatar
84 votes
7 answers
100k views

How to get the short sha for the github workflow?

I am creating a workflow in GitHub which creates and uses a docker image. Therefore I have started my workflow file with a global environment variable for this docker image which is visible for all ...
jactor-rises's user avatar
  • 2,811
83 votes
10 answers
78k views

How to get the commit message in GitHub Actions

I am building an action that does a build for a project that will go to Netlify. In the action, I can pass a deploy message. In that deploy message, I want to pass in the commit message of the commit ...
jrock2004's user avatar
  • 3,341
83 votes
6 answers
168k views

GitHub Actions: Does the IF have an ELSE?

In GitHub Actions: I have an if, but I still need to run some other thing if I'm in the else case. Is there a clean way to do it or do I have to do another step with the same condition at false? - if:...
sab's user avatar
  • 4,842

1
2 3 4 5
217