Skip to content

Commit

Permalink
Only run jobs on master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
TrafeX committed Nov 15, 2023
1 parent 23be629 commit e9d2d43
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ name: Test & build Docker image

on:
push:
branches: [ master ]
tags: ['*']
branches: [master]
tags: ["*"]
pull_request:

env:
IMAGE_NAME: trafex/wordpress
IMAGE_TAG: ${{ github.sha }}
DOCKER_BUILDKIT: 1


jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -39,24 +38,26 @@ jobs:
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: '${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}'
format: 'template'
template: '@/contrib/sarif.tpl'
output: 'trivy-results.sarif'
image-ref: "${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}"
format: "template"
template: "@/contrib/sarif.tpl"
output: "trivy-results.sarif"

- name: Upload Trivy scan results to GitHub Security tab
if: github.ref == 'refs/heads/master' && (github.event_name == 'push' || github.event_name == 'schedule')
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: 'trivy-results.sarif'
sarif_file: "trivy-results.sarif"

- name: Login to Docker Hub
if: (github.ref == 'refs/heads/master' && (github.event_name == 'push' || github.event_name == 'schedule' )) || contains(github.ref, 'refs/tags/')
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build multi-arch image and push latest tag
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
if: github.ref == 'refs/heads/master' && (github.event_name == 'push' || github.event_name == 'schedule')
run: |-
docker buildx build \
--cache-from=$IMAGE_NAME:latest \
Expand Down

0 comments on commit e9d2d43

Please sign in to comment.