Skip to content

Make build dependent on detecting changes on the branch #17

Make build dependent on detecting changes on the branch

Make build dependent on detecting changes on the branch #17

Workflow file for this run

name: Docker Build
on:
push:
# Builds should happen on feature branches
# Only successfully tested builds should be merged to main
# We don't want to rebuild after testing and verifying
branches-ignore:
- 'main'
paths:
- '.github/workflows/dockerBuild.yml'
- 'docker/*'
workflow_dispatch:
jobs:
dockerBuild:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- 'arch'
env:
DockerRepository: ghcr.io/${{ github.repository_owner }}
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 }}