Skip to content

Be more restrictive when fetching default branch #9

Be more restrictive when fetching default branch

Be more restrictive when fetching default branch #9

name: Build Docker Build Env
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/buildDockerBuildEnv.yml'
- 'dockerBuildEnv/*'
workflow_dispatch:
jobs:
dockerBuild:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- 'arch'
- 'clang'
- 'gcc'
env:
defaultBranch: ${{ github.event.repository.default_branch }}
steps:
- uses: actions/checkout@v4
- name: Fetch default branch
run: |
git remote set-branches --add origin "${defaultBranch}"
git fetch --depth 1 origin "${defaultBranch}"
- name: Check for changes
id: diff
run: |
set +e
git diff --exit-code --no-patch "origin/${defaultBranch}" dockerBuildEnv/makefile dockerBuildEnv/nas2d-${{ matrix.platform }}.* ; echo "modified=$?" >> $GITHUB_OUTPUT
- name: Docker build
if: ${{ fromJSON(steps.diff.outputs.modified) }}
run: echo make 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 push-image-${{ matrix.platform }}