Last active
September 8, 2019 09:42
-
-
Save localheinz/57a6ad564251207a430bee50c87c289d to your computer and use it in GitHub Desktop.
GitHub Actions Feature Request: Run job only on `push` to configured branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions | |
on: | |
push: | |
branch: master | |
name: Docker | |
jobs: | |
docker: | |
name: "Docker" | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
image: | |
- php-7.2 | |
- php-7.3 | |
- php-7.3-with-xdebug | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
- name: Docker Login | |
uses: actions/docker/login@master | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD : ${{ secrets.DOCKER_PASSWORD }} | |
- name: "Build and tag Docker image" | |
uses: actions/docker/cli@master | |
with: | |
args: build --tag localheinz/php-library-template-${{ matrix.image }} .docker/${{ matrix.image }} | |
- name: "Push Docker image" | |
uses: actions/docker/cli@master | |
with: | |
args: push localheinz/php-library-template-${{ matrix.image }} | |
- name: Docker Logout | |
uses: actions/docker/cli@master | |
env: | |
args: logout |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions | |
on: | |
- push | |
name: Docker | |
jobs: | |
docker: | |
name: "Docker" | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
image: | |
- php-7.2 | |
- php-7.3 | |
- php-7.3-with-xdebug | |
steps: | |
- name: Checkout | |
if: github.ref == 'refs/heads/master' | |
uses: actions/checkout@master | |
- name: Docker Login | |
if: github.ref == 'refs/heads/master' | |
uses: actions/docker/login@master | |
env: | |
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
DOCKER_PASSWORD : ${{ secrets.DOCKER_PASSWORD }} | |
- name: "Build and tag Docker image" | |
if: github.ref == 'refs/heads/master' | |
uses: actions/docker/cli@master | |
with: | |
args: build --tag localheinz/php-library-template-${{ matrix.image }} .docker/${{ matrix.image }} | |
- name: "Push Docker image" | |
if: github.ref == 'refs/heads/master' | |
uses: actions/docker/cli@master | |
with: | |
args: push localheinz/php-library-template-${{ matrix.image }} | |
- name: Docker Logout | |
if: github.ref == 'refs/heads/master' | |
uses: actions/docker/cli@master | |
env: | |
args: logout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be very nice if it were possible to further configure specifics of a
push
event that trigger a job.Here's a diff:
Currently, the job described in
docker-before.yml
will run on everypush
event, and even though we useif
conditions to skip steps in the jobactions/checkout
andactions/docker/cli
) are buildWe could do better and save resources if the job were only triggered when we push to
master
(or any other specified branch).What do you think, @nat?