11name : Docker Build and Push
2-
32on :
43 push :
54 branches :
65 - main
76 - dev
7+ tags :
8+ - " *" # This will trigger on any tag push
89 pull_request :
910 branches :
1011 - main
11-
1212jobs :
1313 build-and-push :
1414 runs-on : ubuntu-latest
@@ -18,24 +18,30 @@ jobs:
1818 uses : actions/checkout@v3
1919 with :
2020 fetch-depth : 0
21-
21+
2222 # 2) List files to verify huntarr.py is present
2323 - name : List files in directory
2424 run : ls -la
25-
25+
2626 # 3) Set up Docker Buildx
2727 - name : Set up Docker Buildx
2828 uses : docker/setup-buildx-action@v2
29-
29+
3030 # 4) Log in to Docker Hub
3131 - name : Log in to Docker Hub
3232 if : github.event_name != 'pull_request'
3333 uses : docker/login-action@v2
3434 with :
3535 username : ${{ secrets.DOCKERHUB_USERNAME }}
3636 password : ${{ secrets.DOCKERHUB_PASSWORD }}
37-
38- # 5a) Build & Push if on 'main' branch
37+
38+ # 5) Extract version from tag if it's a tag push
39+ - name : Extract version from tag
40+ if : startsWith(github.ref, 'refs/tags/')
41+ id : get_version
42+ run : echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
43+
44+ # 6a) Build & Push if on 'main' branch
3945 - name : Build and Push (main)
4046 if : github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
4147 uses : docker/build-push-action@v3
4450 push : true
4551 tags : |
4652 huntarr/4radarr:latest
47- huntarr/4radarr:py-latest
4853 huntarr/4radarr:${{ github.sha }}
49-
50- # 5b ) Build & Push if on 'dev' branch
54+
55+ # 6b ) Build & Push if on 'dev' branch
5156 - name : Build and Push (dev)
5257 if : github.ref == 'refs/heads/dev' && github.event_name != 'pull_request'
5358 uses : docker/build-push-action@v3
@@ -56,10 +61,20 @@ jobs:
5661 push : true
5762 tags : |
5863 huntarr/4radarr:dev
59- huntarr/4radarr:py-dev
6064 huntarr/4radarr:${{ github.sha }}
6165
62- # 5c) Just build on pull requests
66+ # 6c) Build & Push if it's a tag/release
67+ - name : Build and Push (release)
68+ if : startsWith(github.ref, 'refs/tags/') && github.event_name != 'pull_request'
69+ uses : docker/build-push-action@v3
70+ with :
71+ context : .
72+ push : true
73+ tags : |
74+ huntarr/4radarr:${{ steps.get_version.outputs.VERSION }}
75+ huntarr/4radarr:latest
76+
77+ # 6d) Just build on pull requests
6378 - name : Build (PR)
6479 if : github.event_name == 'pull_request'
6580 uses : docker/build-push-action@v3
0 commit comments