]> git.ipfire.org Git - thirdparty/shairport-sync.git/commitdiff
Refactor Docker workflow for tag handling 5.0.0
authorMike Brady <4265913+mikebrady@users.noreply.github.com>
Sat, 14 Feb 2026 12:54:47 +0000 (12:54 +0000)
committerGitHub <noreply@github.com>
Sat, 14 Feb 2026 12:54:47 +0000 (12:54 +0000)
.github/workflows/docker-on-push-tag-or-pr.yaml

index e7e48352df436d99eeab0c0319595ff17745a750..7282c2f0d6aa31f68005ed745450eef70f2bde0b 100644 (file)
@@ -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 }}