1- name : Build and Push to GHCR & Docker Hub
1+ name : Build and Push to Docker Hub
22
33on :
4- release :
5- types : [published]
6- push :
7- branches : [ main, master ]
8- tags : [ 'v*.*.*' ]
9- pull_request :
10- branches : [ main, master ]
114 workflow_dispatch :
5+ inputs :
6+ tag :
7+ description : ' Docker tag to build (e.g., v1.6.2, latest)'
8+ required : true
9+ type : string
1210
1311jobs :
1412 build-and-push :
1513 runs-on : ubuntu-latest
16- permissions :
17- contents : read
18- packages : write # Needed for GHCR
1914
2015 steps :
2116 - name : Checkout repository
@@ -24,47 +19,18 @@ jobs:
2419 - name : Set up Docker Buildx
2520 uses : docker/setup-buildx-action@v3
2621
27- # Login to GHCR
28- - name : Login to GHCR
29- if : github.event_name != 'pull_request'
30- uses : docker/login-action@v3
31- with :
32- registry : ghcr.io
33- username : ${{ github.actor }}
34- password : ${{ secrets.GITHUB_TOKEN }}
35-
36- # Login to Docker Hub (only on releases/tags)
3722 - name : Login to Docker Hub
38- if : github.event_name == 'release' || startsWith(github.ref, 'refs/tags/v')
3923 uses : docker/login-action@v3
4024 with :
4125 username : 1minds3t
4226 password : ${{ secrets.DOCKERHUB_TOKEN }}
4327
44- # Extract metadata/tags for BOTH registries
45- - name : Extract metadata (tags, labels)
46- id : meta
47- uses : docker/metadata-action@v5
48- with :
49- images : |
50- ghcr.io/${{ github.repository }}
51- ${{ (github.event_name == 'release' || startsWith(github.ref, 'refs/tags/v')) && '1minds3t/omnipkg' || '' }}
52- tags : |
53- type=ref,event=branch
54- type=ref,event=pr
55- type=semver,pattern={{version}}
56- type=semver,pattern={{major}}.{{minor}}
57- type=raw,value=latest,enable={{is_default_branch}}
58- type=sha
59-
60- # Build and push
6128 - name : Build and push
6229 uses : docker/build-push-action@v5
6330 with :
6431 context : .
6532 platforms : linux/amd64,linux/arm64
66- push : ${{ github.event_name != 'pull_request' }}
67- tags : ${{ steps.meta.outputs.tags }}
68- labels : ${{ steps.meta.outputs.labels }}
33+ push : true
34+ tags : 1minds3t/omnipkg:${{ inputs.tag }}
6935 cache-from : type=gha
7036 cache-to : type=gha,mode=max
0 commit comments