From: Mike Brady <4265913+mikebrady@users.noreply.github.com> Date: Sat, 14 Feb 2026 12:54:47 +0000 (+0000) Subject: Refactor Docker workflow for tag handling X-Git-Tag: 5.0.0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7421421848519d494f2152dc5810115c0b030ca2;p=thirdparty%2Fshairport-sync.git Refactor Docker workflow for tag handling --- diff --git a/.github/workflows/docker-on-push-tag-or-pr.yaml b/.github/workflows/docker-on-push-tag-or-pr.yaml index e7e48352..7282c2f0 100644 --- a/.github/workflows/docker-on-push-tag-or-pr.yaml +++ b/.github/workflows/docker-on-push-tag-or-pr.yaml @@ -1,10 +1,10 @@ # Builds and pushes a docker image in the following scenarios: # When a commit is made to 'master' or 'development'. # Tag pattern -# 'master' - rolling, rolling-classic -# 'development' - development, development-classic -# When a tag is created. -# Tag pattern: '[tag]' & '[tag]-classic', plus 'latest' & 'classic' +# 'master' branch - rolling, rolling-classic (for commits) +# - [tag], [tag]-classic, latest, classic (for tags) +# 'development' branch - development, development-classic (for all pushes including tags) +# Builds but does not push a docker image for PRs. name: Build and conditionally push docker image on: workflow_dispatch: @@ -37,6 +37,27 @@ jobs: SHAIRPORT_SYNC_BRANCH=. NQPTP_BRANCH=${{ needs.docker-vars.outputs.nqptp_branch }} steps: + - name: Checkout shairport sync repo + uses: actions/checkout@v6.0.2 + with: + fetch-depth: 0 + + - name: Determine which branch the tag belongs to + id: determine_branch + if: github.ref_type == 'tag' + run: | + # Check which branch contains this tag + if git branch -r --contains ${{ github.sha }} | grep -q 'origin/master'; then + echo "branch=master" >> $GITHUB_OUTPUT + echo "Tag ${{ github.ref_name }} is on master branch" + elif git branch -r --contains ${{ github.sha }} | grep -q 'origin/development'; then + echo "branch=development" >> $GITHUB_OUTPUT + echo "Tag ${{ github.ref_name }} is on development branch" + else + echo "branch=unknown" >> $GITHUB_OUTPUT + echo "Warning: Tag ${{ github.ref_name }} is not on master or development branch" + fi + - name: Login to Docker Registry uses: docker/login-action@v3.7.0 with: @@ -44,14 +65,13 @@ jobs: username: ${{ secrets.DOCKER_REGISTRY_USER }} password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} if: needs.docker-vars.outputs.push_docker_image == 'true' + - name: Set up QEMU uses: docker/setup-qemu-action@v3.7.0 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3.12.0 - - name: Checkout shairport sync repo - uses: actions/checkout@v6.0.2 - with: - fetch-depth: 0 + - name: Build and push ${{ matrix.name }} uses: docker/build-push-action@v6.18.0 env: @@ -67,17 +87,21 @@ jobs: && format('{0}:development', env.registry_and_name) || '' }} ${{ github.ref_type == 'branch' && github.ref_name == 'development' && matrix.name == 'classic' && format('{0}:development-classic', env.registry_and_name) || '' }} + ${{ github.ref_type == 'tag' && steps.determine_branch.outputs.branch == 'development' && matrix.name == 'main' + && format('{0}:development', env.registry_and_name) || '' }} + ${{ github.ref_type == 'tag' && steps.determine_branch.outputs.branch == 'development' && matrix.name == 'classic' + && format('{0}:development-classic', env.registry_and_name) || '' }} ${{ github.ref_type == 'branch' && github.ref_name == 'master' && matrix.name == 'main' && format('{0}:rolling', env.registry_and_name) || '' }} ${{ github.ref_type == 'branch' && github.ref_name == 'master' && matrix.name == 'classic' && format('{0}:rolling-classic', env.registry_and_name) || '' }} - ${{ github.ref_type == 'tag' && matrix.name == 'main' + ${{ github.ref_type == 'tag' && steps.determine_branch.outputs.branch == 'master' && matrix.name == 'main' && format('{0}:{1}', env.registry_and_name, github.ref_name) || '' }} - ${{ github.ref_type == 'tag' && matrix.name == 'classic' + ${{ github.ref_type == 'tag' && steps.determine_branch.outputs.branch == 'master' && matrix.name == 'classic' && format('{0}:{1}-classic', env.registry_and_name, github.ref_name) || '' }} - ${{ github.ref_type == 'tag' && matrix.name == 'main' + ${{ github.ref_type == 'tag' && steps.determine_branch.outputs.branch == 'master' && matrix.name == 'main' && format('{0}:latest', env.registry_and_name) || '' }} - ${{ github.ref_type == 'tag' && matrix.name == 'classic' + ${{ github.ref_type == 'tag' && steps.determine_branch.outputs.branch == 'master' && matrix.name == 'classic' && format('{0}:classic', env.registry_and_name) || '' }} build-args: | ${{ matrix.build_args }}