Skip to content

Commit

Permalink
Make build dependent on detecting changes on the branch
Browse files Browse the repository at this point in the history
We only run the workflow when there are changes to the docker folder (or the workflow itself), and we only want to run jobs for platforms that have an updated Docker image to build.
  • Loading branch information
DanRStevens committed Oct 29, 2024
1 parent fb3b603 commit 183a4c4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/dockerBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,25 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Fetch main
run: |
git remote set-branches --add origin main
git fetch --depth 1
- name: Check for changes
id: diff
run: |
set +e
git diff --exit-code --no-patch origin/main docker/nas2d-${{ matrix.platform }}.* ; echo "modified=$?" >> $GITHUB_OUTPUT
- name: Docker build
if: ${{ fromJSON(steps.diff.outputs.modified) }}
run: make -C docker build-image-${{ matrix.platform }}

- name: Docker login
if: ${{ fromJSON(steps.diff.outputs.modified) }}
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username "${{ github.repository_owner }}" --password-stdin

- name: Docker push
if: ${{ fromJSON(steps.diff.outputs.modified) }}
run: make -C docker push-image-${{ matrix.platform }}

0 comments on commit 183a4c4

Please sign in to comment.