I have a repository in GitHub and I want to create an Action to build a Docker image and push it to the DockerHub. I know how to do it but if I create the action in a branch other than master, GitHub does not run it.
This is a known problem (Workflow files only picked up from master?).
Any ideas to fix it?
Github actions can only trigger on master or the default branch.
On GitHub.com, navigate to the main page of the repository. Under your repository name, click Actions. In the left sidebar, click the workflow you want to run. Above the list of workflow runs, select Run workflow.
GitHub Actions uses YAML syntax to define the workflow. Each workflow is stored as a separate YAML file in your code repository, in a directory named . github/workflows .
To run jobs sequentially, you can define dependencies on other jobs using the jobs. <job_id>. needs keyword. Each job runs in a runner environment specified by runs-on .
According to the official GitHub Actions documentation (About workflow events):
The following steps occur to trigger a workflow run:
An event occurs on your repository, and the resulting event webhook has an associated commit SHA and Git ref.
The .github/workflows directory in your repository is searched for workflow files at the associated commit SHA or Git ref. The workflow files must be present in that commit SHA or Git ref to be considered.
For example, if the event occurred on a particular repository branch, then the workflow files must be present in the repository on that branch.The workflow files for that commit SHA and Git ref are inspected, and a new workflow run is triggered for any workflows that have on: values that match the triggering event.
The workflow runs on your repository's code at the same commit SHA and Git ref that triggered the event. When a workflow runs, GitHub sets the GITHUB_SHA (commit SHA) and GITHUB_REF (Git ref) environment variables in the runner environment. For more information, see "Using environment variables."
Because of this, in order to test the workflows we need to perform a git action (ie. do push
) in the created branch.
What has worked for me (through trial and error)
'.github'
path trigger).on: push: paths: - 'path/to/your/code/**'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With