Skip to content

Commit 0f208c7

Browse files
authored
ci: split Docker workflow into separate stg and prd files (#78)
1 parent 527d73c commit 0f208c7

File tree

4 files changed

+89
-58
lines changed

4 files changed

+89
-58
lines changed
Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
name: Build Docker image
1+
name: Build production Docker images
22

33
on:
4-
push:
5-
branches:
6-
- 'main'
74
release:
85
types:
96
- published
@@ -12,59 +9,7 @@ env:
129
REGISTRY: ghcr.io
1310

1411
jobs:
15-
build-stg:
16-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
17-
runs-on: ubuntu-latest
18-
permissions:
19-
contents: read
20-
packages: write
21-
steps:
22-
- name: Checkout repository
23-
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
24-
25-
- name: Set up QEMU
26-
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7
27-
28-
- name: Set up Docker Buildx
29-
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55
30-
31-
- name: Log into registry ${{ env.REGISTRY }}
32-
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
33-
with:
34-
registry: ${{ env.REGISTRY }}
35-
username: ${{ github.actor }}
36-
password: ${{ secrets.GITHUB_TOKEN }}
37-
38-
- name: Extract Docker metadata
39-
id: meta
40-
uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175
41-
with:
42-
images: ${{ env.REGISTRY }}/${{ github.repository }}
43-
tags: |
44-
type=raw,value=main
45-
type=raw,value=latest
46-
type=raw,value=latest-${{ github.sha }}
47-
48-
- name: Replace .env.production with .env.stage
49-
shell: bash
50-
run: |
51-
rm .env.production
52-
mv .env.stage .env.production
53-
if: github.ref == 'refs/heads/main'
54-
55-
- name: Build and push Docker image
56-
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6
57-
with:
58-
context: .
59-
file: Dockerfile
60-
push: true
61-
tags: ${{ steps.meta.outputs.tags }}
62-
labels: ${{ steps.meta.outputs.labels }}
63-
build-args: |
64-
NEXT_PUBLIC_APP_VERSION=latest-${{ github.sha }}
65-
6612
build-prd:
67-
if: github.event_name == 'release'
6813
runs-on: ubuntu-latest
6914
permissions:
7015
contents: read
@@ -116,7 +61,6 @@ jobs:
11661
NEXT_PUBLIC_APP_VERSION=stable-${{ steps.stable_sha.outputs.value }}
11762
11863
build-prd-ibw:
119-
if: github.event_name == 'release'
12064
runs-on: ubuntu-latest
12165
permissions:
12266
contents: read
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build staging Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
11+
jobs:
12+
build-stg:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744
20+
21+
- name: Set up QEMU
22+
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55
26+
27+
- name: Log into registry ${{ env.REGISTRY }}
28+
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
29+
with:
30+
registry: ${{ env.REGISTRY }}
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Extract Docker metadata
35+
id: meta
36+
uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175
37+
with:
38+
images: ${{ env.REGISTRY }}/${{ github.repository }}
39+
tags: |
40+
type=raw,value=main
41+
type=raw,value=latest
42+
type=raw,value=latest-${{ github.sha }}
43+
44+
- name: Replace .env.production with .env.stage
45+
shell: bash
46+
run: |
47+
rm .env.production
48+
mv .env.stage .env.production
49+
50+
- name: Build and push Docker image
51+
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6
52+
with:
53+
context: .
54+
file: Dockerfile
55+
push: true
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
build-args: |
59+
NEXT_PUBLIC_APP_VERSION=latest-${{ github.sha }}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"release:rc": "standard-version --prerelease rc --no-verify",
4848
"release:rc:dry": "standard-version --dry-run --prerelease rc",
4949
"release": "standard-version",
50-
"release:dry": "standard-version --dry-run"
50+
"release:dry": "standard-version --dry-run",
51+
"release:publish": "bash scripts/release-publish.sh"
5152
},
5253
"dependencies": {
5354
"@azure/identity": "3.3.0",

scripts/release-publish.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
5+
if [[ "$BRANCH" != "main" ]]; then
6+
echo "❌ Must be on 'main' branch (currently on '$BRANCH')"
7+
exit 1
8+
fi
9+
10+
if [[ -n "$(git status --porcelain)" ]]; then
11+
echo "❌ Working directory is not clean. Commit or stash changes first."
12+
exit 1
13+
fi
14+
15+
echo "📦 Running standard-version..."
16+
pnpm run release
17+
18+
VERSION=$(node -p "require('./package.json').version")
19+
TAG="v$VERSION"
20+
21+
echo "🚀 Pushing commit and tag ($TAG) to origin/main..."
22+
git push --follow-tags origin main
23+
24+
echo "📢 Creating GitHub Release $TAG..."
25+
gh release create "$TAG" --target main --generate-notes --title "$TAG"
26+
27+
echo "✅ Release $TAG published. build-prd and build-prd-ibw will start shortly."

0 commit comments

Comments
 (0)