1+ name : Docker Image
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ tag :
7+ description : ' Tag'
8+ required : true
9+ release :
10+ types : [created]
11+
12+ env :
13+ REGISTRY : ghcr.io
14+ IMAGE_NAME : ${{ github.repository }}
15+ VERSION : ${{ github.event.inputs.tag || github.event.release.tag_name || '' }}
16+
17+ jobs :
18+ build-and-push :
19+ runs-on : k8s-infrastructure-dind
20+
21+ permissions :
22+ contents : read
23+ packages : write
24+
25+ steps :
26+ - name : Checkout repository
27+ uses : actions/checkout@v4
28+
29+ - name : Set up Docker Buildx
30+ uses : docker/setup-buildx-action@v3
31+
32+ - name : Log in to the Container registry
33+ uses : docker/login-action@v3
34+ with :
35+ registry : ${{ env.REGISTRY }}
36+ username : ${{ github.actor }}
37+ password : ${{ secrets.GITHUB_TOKEN }}
38+
39+ - name : Check if VERSION follows the x.x.x format
40+ run : |
41+ if [[ "${{ env.VERSION }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
42+ echo "LATEST_TAG_ENABLED=true" >> $GITHUB_ENV
43+ else
44+ echo "LATEST_TAG_ENABLED=false" >> $GITHUB_ENV
45+ fi
46+
47+ - name : Extract metadata (tags, labels) for Docker
48+ id : meta
49+ uses : docker/metadata-action@v5
50+ with :
51+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
52+ tags : |
53+ type=sha
54+ type=semver,pattern={{version}},value=${{ env.VERSION }}
55+ type=raw,value=latest,enable=${{ env.LATEST_TAG_ENABLED == 'true' }}
56+ type=raw,value=testnet
57+ flavor : |
58+ latest=false
59+
60+ - name : Build and push Docker image
61+ id : push
62+ uses : docker/build-push-action@v5
63+ with :
64+ context : .
65+ platforms : linux/amd64,linux/arm64
66+ push : true
67+ tags : ${{ steps.meta.outputs.tags }}
68+ labels : ${{ steps.meta.outputs.labels }}
69+ cache-from : type=gha
70+ cache-to : type=gha,mode=max
71+ build-args : |
72+ VERSION=${{ env.VERSION }}
0 commit comments