1+ name : Build & publish Namada image
2+
3+ # —————————————————————————————————————————
4+ # 1. Run ONLY when we push a tag ‘v<node>-<imgRev>’ (e.g. v1.1.0-1beta)
5+ # —————————————————————————————————————————
6+ on :
7+ push :
8+ tags : [ 'v*-*' ] # any vX.Y.Z-whatever
9+
10+ env :
11+ REGISTRY : ghcr.io
12+ IMAGE_NAME : ${{ github.repository }} # ghcr.io/<owner>/<repo>
13+
14+ jobs :
15+ build :
16+ runs-on : ubuntu-latest
17+ permissions :
18+ contents : read # checkout
19+ packages : write # push to GHCR
20+
21+ steps :
22+ # ————————————————————————————————————————
23+ # 2. Grab the code
24+ # ————————————————————————————————————————
25+ - name : Checkout repo
26+ uses : actions/checkout@v4
27+
28+
29+ # ————————————————————————————————————————
30+ # 3. Work out the two versions from the tag
31+ # tag=v1.1.0-1beta → node=1.1.0 imgRev=1beta
32+ # ————————————————————————————————————————
33+ - name : Parse tag parts
34+ id : versions
35+ run : |
36+ TAG="${GITHUB_REF#refs/tags/}" # e.g. v1.1.0-1beta
37+ NODE_VERSION="${TAG%%-*}" # v1.1.0
38+ IMAGE_REV="${TAG#*-}" # 1beta
39+ echo "NODE_VERSION=$NODE_VERSION" >> "$GITHUB_OUTPUT"
40+ echo "IMAGE_REV=$IMAGE_REV" >> "$GITHUB_OUTPUT"
41+ echo "GIT_TAG=$TAG" >> "$GITHUB_OUTPUT"
42+
43+ # ————————————————————————————————————————
44+ # 4. Log in to the container registry
45+ # ————————————————————————————————————————
46+ - name : Log in to GHCR
47+ uses : docker/login-action@v3
48+ with :
49+ registry : ghcr.io
50+ username : ${{ github.actor }}
51+ password : ${{ secrets.GITHUB_TOKEN }}
52+ - uses : docker/setup-buildx-action@v3
53+
54+ # ————————————————————————————————————————
55+ # 5. Create the image tag list (just the Git tag)
56+ # ————————————————————————————————————————
57+ - name : Generate Docker tags
58+ id : meta
59+ uses : docker/metadata-action@v5
60+ with :
61+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
62+ tags : |
63+ type=raw,value=${{ steps.versions.outputs.GIT_TAG }}
64+ visibility : public
65+
66+ # ————————————————————————————————————————
67+ # 6. Build & push
68+ # ————————————————————————————————————————
69+ - name : Build and push
70+ uses : docker/build-push-action@v5
71+ with :
72+ context : .
73+ push : true
74+ platforms : linux/amd64 # add ,linux/arm64 if you need multi‑arch
75+ tags : ${{ steps.meta.outputs.tags }}
76+ labels : ${{ steps.meta.outputs.labels }}
77+ build-args : |
78+ NAMADA_VERSION=${{ steps.versions.outputs.NODE_VERSION }}
79+ cache-from : type=gha,scope=${{ github.ref_name }}
80+ cache-to : type=gha,mode=max,scope=${{ github.ref_name }}
0 commit comments