1- name : Docker Push
1+ name : Publish docker image
2+
23on :
3- push :
4- tags : ['v*']
4+ workflow_dispatch :
5+ inputs :
6+ release_tag :
7+ description : ' Tag to release'
8+ required : true
9+ type : string
10+
11+ permissions :
12+ contents : read
13+ packages : write
14+
515jobs :
6- build :
7- runs-on : ubuntu-latest
8- environment : main
9- steps :
10- - name : Check out code
11- uses : actions/checkout@v4
12- - name : Log in to Docker Hub
13- run : echo $DOCKER_TOKEN | docker login --username=anishathalye --password-stdin
14- env :
15- DOCKER_TOKEN : ${{ secrets.DOCKER_TOKEN }}
16- - name : Compute tag
17- id : tag
18- run : echo ::set-output name=TAG ::anishathalye/proof-html:${GITHUB_REF#refs/tags/v}
19- - name : Build image
20- run : docker build . -t ${{ steps.tag.outputs.TAG }}
21- - name : Publish image
22- run : docker push ${{ steps.tag.outputs.TAG }}
16+ build :
17+ runs-on : ubuntu-latest
18+ if : startsWith(github.event.inputs.release_tag, 'v')
19+ steps :
20+ - name : Harden the runner (Audit all outbound calls)
21+ uses : step-security/harden-runner@v2
22+ with :
23+ egress-policy : audit
24+
25+ - name : Checkout
26+ uses : actions/checkout@v5
27+ - name : Validate tag format
28+ run : |
29+ TAG=${{ github.event.inputs.release_tag }}
30+ if ! echo "$TAG" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
31+ echo "❌ Invalid tag format: $TAG"
32+ exit 1
33+ fi
34+ echo "✅ Valid semver tag: $TAG"
35+ - name : Log in to GitHub Container Registry
36+ uses : docker/login-action@v3
37+ with :
38+ registry : ghcr.io
39+ username : ${{ github.actor }}
40+ password : ${{ secrets.GITHUB_TOKEN }}
41+
42+ - name : Set up QEMU for ARM builds
43+ uses : docker/setup-qemu-action@v3
44+
45+ - name : Set up Docker Buildx
46+ uses : docker/setup-buildx-action@v3
47+
48+ - name : Build and push Docker image
49+ uses : docker/build-push-action@v6
50+ with :
51+ context : .
52+ push : true
53+ platforms : linux/amd64,linux/arm64
54+ tags : |
55+ ghcr.io/${{ github.repository }}:${{ github.event.inputs.release_tag }}
0 commit comments