11name : Build & Push - Dev
2- # Automatically builds and pushes a multi-platform dev image based on commits involving key files
2+ # Automatically builds and pushes a multi-platform dev image based on commits involving key files in any branch
33
44on :
55 push :
6+ branches :
7+ - ' **' # Runs on pushes to any branch
68 paths :
79 - ' empty_library/**'
810 - ' root/**'
911 - ' scripts/**'
1012 - ' **/Dockerfile'
13+ create :
14+ branches :
15+ - ' **' # Runs when a new branch is created
1116
1217jobs :
1318 build :
1419 runs-on : ubuntu-latest
20+ if : github.event.ref_type == 'branch' || github.event_name == 'push' # Ensures it runs for branch creation & push events
1521
1622 steps :
17- - uses : actions/checkout@v4
23+ - name : Checkout correct branch
24+ uses : actions/checkout@v4
25+ with :
26+ ref : ${{ github.ref }}
27+
28+ - name : Determine Docker Image Tag
29+ id : tag
30+ run : |
31+ if [[ "${{ github.ref_name }}" == "main" ]]; then
32+ echo "IMAGE_TAG=dev" >> $GITHUB_ENV
33+ else
34+ echo "IMAGE_TAG=dev-${{ github.ref_name }}" >> $GITHUB_ENV
35+ fi
1836
1937 - name : DockerHub Login
2038 uses : docker/login-action@v3
@@ -31,15 +49,15 @@ jobs:
3149 - name : Build and push Docker image
3250 uses : docker/build-push-action@v6
3351 with :
34- provenance : false # Disable provenance metadata to fix BuildKit issues
52+ provenance : false # Disable provenance metadata to fix BuildKit issues
3553 context : .
3654 file : ./Dockerfile
3755 push : true
3856 build-args : |
3957 BUILD_DATE=${{ github.event.repository.updated_at }}
40- VERSION=${{ vars.CURRENT_DEV_VERSION }}-DEV_BUILD-${{ vars.CURRENT_DEV_BUILD_NUM }}
58+ VERSION=${{ vars.CURRENT_DEV_VERSION }}-DEV_BUILD-${{ env.IMAGE_TAG }}-${{ vars.CURRENT_DEV_BUILD_NUM }}
4159 tags : |
42- ${{ secrets.DOCKERHUB_USERNAME }}/calibre-web-automated:dev
60+ ${{ secrets.DOCKERHUB_USERNAME }}/calibre-web-automated:dev-${{ env.IMAGE_TAG }}
4361
4462 platforms : linux/amd64,linux/arm64
4563
0 commit comments