Skip to content

Commit 58fadd0

Browse files
authored
Merge pull request #1470 from CodeForAfrica/apps-pr-build-targets
Add affected app PR image builds
2 parents c50317f + 74729f1 commit 58fadd0

11 files changed

Lines changed: 573 additions & 46 deletions
Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: Bake and Push
1+
name: Reusable | Bake and Push
22

33
permissions:
44
contents: read
55
actions: read
66

7-
# Reusable workflow for building and pushing a bake target.
7+
# Reusable workflow for building and optionally pushing a bake target.
88
# Replaces build-docker-image.yml for apps migrated to docker-bake.hcl.
99
#
1010
# Callers pass app-specific build args via the `set` input using GitHub Variables
@@ -25,22 +25,26 @@ on:
2525
required: true
2626
type: string
2727
description: >
28-
JSON string. Target OS (e.g. ubuntu-24.04-arm or
29-
['ubuntu-24.04-arm', 'ubuntu-24.04']) of the image
28+
JSON string passed to runs-on via fromJSON, e.g.
29+
["ubuntu-24.04-arm"].
3030
tag:
3131
required: true
3232
type: string
33-
description: "Image tag to push (e.g. git SHA or semver)"
33+
description: "Image tag to build or push (e.g. git SHA or semver)"
34+
push:
35+
required: false
36+
type: boolean
37+
default: true
38+
description: "Whether to push the built image to the registry"
3439
base_tag:
3540
required: false
3641
type: string
3742
default: ""
3843
description: >
3944
Pre-built base image tag (BASE_TAG). When set, pulls ui-builder-base
4045
and ui-runner-base from the registry instead of building them inline.
41-
Use this in CI to avoid rebuilding base images on every app push.
42-
Omit (or leave empty) to build base images inline — useful when
43-
testing base image changes locally via act or in build-base-images.yml.
46+
Required for CI app builds so they reuse published base images rather
47+
than rebuilding base images inline.
4448
set:
4549
required: false
4650
type: string
@@ -56,9 +60,9 @@ on:
5660
DATABASE_URL:
5761
required: false
5862
DOCKER_HUB_USERNAME:
59-
required: true
63+
required: false
6064
DOCKER_HUB_ACCESS_TOKEN:
61-
required: true
65+
required: false
6266
PAYLOAD_SECRET:
6367
required: false
6468
SENTRY_AUTH_TOKEN:
@@ -82,14 +86,21 @@ jobs:
8286
id: meta
8387
run: echo "date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
8488

89+
- name: Validate base image tag
90+
if: ${{ inputs.base_tag == '' }}
91+
run: |
92+
echo "::error::base_tag is required for CI app builds. Build and publish base images, then set vars.UI_BASE_TAG."
93+
exit 1
94+
8595
- uses: docker/setup-buildx-action@v4
8696

8797
- uses: docker/login-action@v4
98+
if: ${{ inputs.push }}
8899
with:
89100
username: ${{ secrets.DOCKER_HUB_USERNAME }}
90101
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
91102

92-
- name: Build and push
103+
- name: Build with Docker bake
93104
uses: docker/bake-action@v7
94105
env:
95106
TAG: ${{ inputs.tag }}
@@ -104,7 +115,7 @@ jobs:
104115
with:
105116
files: docker-bake.hcl
106117
targets: ${{ inputs.target }}
107-
push: true
118+
push: ${{ inputs.push }}
108119
set: |
109120
*.cache-from=type=gha,scope=${{ inputs.target }}
110121
*.cache-to=type=gha,mode=max,scope=${{ inputs.target }}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Reusable Build | TechLab Blog
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
tag:
7+
required: true
8+
type: string
9+
description: "Image tag to build or push"
10+
push:
11+
required: true
12+
type: boolean
13+
description: "Whether to push the built image to the registry"
14+
base_tag:
15+
required: true
16+
type: string
17+
description: "Published base image tag to build from"
18+
sentry_environment:
19+
required: true
20+
type: string
21+
description: "Sentry environment baked into the app"
22+
set:
23+
required: false
24+
type: string
25+
default: ""
26+
description: "Additional bake --set overrides"
27+
secrets:
28+
DOCKER_HUB_USERNAME:
29+
required: false
30+
DOCKER_HUB_ACCESS_TOKEN:
31+
required: false
32+
SENTRY_AUTH_TOKEN:
33+
required: false
34+
SENTRY_ORG:
35+
required: false
36+
SENTRY_PROJECT:
37+
required: false
38+
39+
jobs:
40+
build:
41+
permissions:
42+
actions: read
43+
contents: read
44+
uses: ./.github/workflows/_bake-and-push.yml
45+
with:
46+
target: techlabblog
47+
target_os: '["ubuntu-24.04-arm"]'
48+
base_tag: ${{ inputs.base_tag }}
49+
tag: ${{ inputs.tag }}
50+
push: ${{ inputs.push }}
51+
# Stable app-level config lives here so PR and main builds share one build contract.
52+
set: |
53+
techlabblog.args.SENTRY_DSN=${{ vars.TECHLABBLOG_SENTRY_DSN }}
54+
techlabblog.args.SENTRY_ENVIRONMENT=${{ inputs.sentry_environment }}
55+
${{ inputs.set }}
56+
secrets:
57+
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
58+
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
59+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
60+
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
61+
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Reusable Build | TrustLab
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
tag:
7+
required: true
8+
type: string
9+
description: "Image tag to build or push"
10+
push:
11+
required: true
12+
type: boolean
13+
description: "Whether to push the built image to the registry"
14+
base_tag:
15+
required: true
16+
type: string
17+
description: "Published base image tag to build from"
18+
set:
19+
required: false
20+
type: string
21+
default: ""
22+
description: "Additional bake --set overrides"
23+
secrets:
24+
DATABASE_URL:
25+
required: false
26+
DOCKER_HUB_USERNAME:
27+
required: false
28+
DOCKER_HUB_ACCESS_TOKEN:
29+
required: false
30+
PAYLOAD_SECRET:
31+
required: false
32+
SENTRY_AUTH_TOKEN:
33+
required: false
34+
SENTRY_ORG:
35+
required: false
36+
SENTRY_PROJECT:
37+
required: false
38+
39+
jobs:
40+
build:
41+
permissions:
42+
actions: read
43+
contents: read
44+
uses: ./.github/workflows/_bake-and-push.yml
45+
with:
46+
target: trustlab
47+
target_os: '["ubuntu-24.04-arm"]'
48+
base_tag: ${{ inputs.base_tag }}
49+
tag: ${{ inputs.tag }}
50+
push: ${{ inputs.push }}
51+
set: ${{ inputs.set }}
52+
secrets:
53+
DATABASE_URL: ${{ secrets.DATABASE_URL }}
54+
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
55+
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
56+
PAYLOAD_SECRET: ${{ secrets.PAYLOAD_SECRET }}
57+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
58+
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
59+
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}

.github/workflows/ci.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@ jobs:
2424
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
2525
strategy:
2626
matrix:
27-
node-version: [24]
2827
os: [ubuntu-latest]
2928
steps:
3029
- name: Checkout
31-
uses: actions/checkout@v4
30+
uses: actions/checkout@v6
3231
with:
3332
fetch-depth: 2
3433

3534
# https://github.com/pnpm/action-setup#use-cache-to-reduce-installation-time
3635
- name: Install pnpm
37-
uses: pnpm/action-setup@v4
36+
uses: pnpm/action-setup@v6
3837
id: pnpm-install
3938
with:
4039
run_install: false
@@ -46,7 +45,7 @@ jobs:
4645
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
4746
4847
- name: Setup pnpm cache
49-
uses: actions/cache@v4
48+
uses: actions/cache@v5
5049
with:
5150
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
5251
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
@@ -56,9 +55,9 @@ jobs:
5655
# Looks like to use pnpm cache, setup-node must run after pnpm/action-setup
5756
# https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data
5857
- name: Install Node.js
59-
uses: actions/setup-node@v4
58+
uses: actions/setup-node@v6
6059
with:
61-
node-version: ${{ matrix.node-version }}
60+
node-version-file: "package.json"
6261
cache: "pnpm"
6362

6463
- name: Confirm pnpm version
@@ -67,16 +66,18 @@ jobs:
6766
- name: Install dependencies
6867
run: pnpm install
6968

69+
# root task
70+
# https://turborepo.dev/docs/guides/tools/oxc#create-root-tasks-1
7071
- name: Format
71-
run: pnpm format:check
72+
run: pnpm exec turbo format:check
7273

7374
- name: Lint
7475
run: pnpm lint:check
7576

7677
# Standard linux runners for public repositories have 4 vCPUs and 16GB of RAM
7778
# see: https://docs.github.com/en/actions/reference/runners/github-hosted-runners#standard-github-hosted-runners-for-public-repositories
78-
- name: Jest
79-
run: pnpm jest:ci
79+
- name: Test
80+
run: pnpm test:ci
8081

8182
# TODO: Re-enable build in a dedicated CI build cleanup PR. The current
8283
# build surface needs app-scoped env isolation for Payload/Next apps.

0 commit comments

Comments
 (0)