Skip to content

Commit 18d7e34

Browse files
authored
Merge pull request #106 from DataSQRL/ci/parameterize-sqrl-image
ci: Parameterize SQRL image via workflow_dispatch for snapshot validation
2 parents 77d33fa + 6659466 commit 18d7e34

1 file changed

Lines changed: 60 additions & 10 deletions

File tree

.github/workflows/build.yml

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
name: Build and test DataSQRL Examples
22

3+
run-name: examples build [${{ inputs.correlation_id || github.run_number }}]
4+
35
on:
46
push:
57
branches: [ "main" ]
68
pull_request:
9+
workflow_dispatch:
10+
inputs:
11+
sqrl_image:
12+
description: "Full SQRL CLI image reference (e.g. ghcr.io/datasqrl/cmd:pr-123 or datasqrl/cmd:dev). When set, overrides SQRL_VERSION and skips Docker Hub publishing."
13+
required: false
14+
default: ''
15+
correlation_id:
16+
description: "Optional correlation ID used by upstream dispatchers to locate this run."
17+
required: false
18+
default: ''
719

820
concurrency:
9-
group: ${{ github.workflow }}-${{ github.ref }}
21+
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.correlation_id || github.run_id }}
1022
cancel-in-progress: true
1123

1224
env:
@@ -17,6 +29,9 @@ jobs:
1729
build-and-push:
1830
runs-on: ubuntu-latest-4-cores
1931
timeout-minutes: 30
32+
permissions:
33+
id-token: write
34+
contents: read
2035

2136
strategy:
2237
fail-fast: false
@@ -150,6 +165,20 @@ jobs:
150165
steps:
151166
- uses: actions/checkout@v4
152167

168+
- name: Resolve SQRL image
169+
id: resolve-image
170+
run: |
171+
if [ -n "${{ inputs.sqrl_image }}" ]; then
172+
IMAGE="${{ inputs.sqrl_image }}"
173+
IS_SNAPSHOT=true
174+
else
175+
IMAGE="datasqrl/cmd:${SQRL_VERSION}"
176+
IS_SNAPSHOT=false
177+
fi
178+
echo "image=$IMAGE" >> "$GITHUB_OUTPUT"
179+
echo "is_snapshot=$IS_SNAPSHOT" >> "$GITHUB_OUTPUT"
180+
echo "Using SQRL image: $IMAGE (snapshot=$IS_SNAPSHOT)"
181+
153182
- name: Setup Timezone
154183
uses: szenius/set-timezone@v1.1
155184
with:
@@ -158,18 +187,30 @@ jobs:
158187
- name: Cache Docker images
159188
uses: ScribeMD/docker-cache@0.5.0
160189
with:
161-
# one cache entry per SQRL version & OS
162-
key: sqrl-${{ runner.os }}-${{ env.SQRL_VERSION }}
190+
# one cache entry per SQRL image ref & OS
191+
key: sqrl-${{ runner.os }}-${{ steps.resolve-image.outputs.image }}
163192

164193
- name: Pull SQRL Docker image
165-
run: docker pull datasqrl/cmd:${{ env.SQRL_VERSION }}
194+
run: docker pull "${{ steps.resolve-image.outputs.image }}"
195+
196+
- name: Configure AWS credentials via OIDC
197+
# Tolerated: PRs from forks cannot mint an OIDC token for this repo's role.
198+
# Such PRs fall back to running without AWS credentials, which is fine for
199+
# every matrix entry except the S3-backed iceberg canary.
200+
continue-on-error: true
201+
uses: aws-actions/configure-aws-credentials@v4
202+
with:
203+
role-to-assume: ${{ secrets.AWS_DEV_GITHUB_ACTION_ROLE }}
204+
aws-region: us-east-1
166205

167206
- name: Run ${{ matrix.example }} Tests
168207
working-directory: ${{ matrix.path }}
208+
env:
209+
SQRL_IMAGE: ${{ steps.resolve-image.outputs.image }}
169210
run: |
170211
# Read raw lines from the matrix value
171212
mapfile -t raw_cmds <<< "${{ matrix.test_commands }}"
172-
213+
173214
# Keep only non‑empty lines
174215
cmds=()
175216
for c in "${raw_cmds[@]}"; do
@@ -185,35 +226,44 @@ jobs:
185226
for cmd in "${cmds[@]}"; do
186227
echo "::group::Running: $cmd"
187228
docker run -i -p 8888:8888 -p 8081:8081 -p 9092:9092 \
188-
-e AWS_ACCESS_KEY_ID="${{ secrets.AWS_ACCESS_KEY_ID }}" \
189-
-e AWS_SECRET_ACCESS_KEY="${{ secrets.AWS_SECRET_ACCESS_KEY }}" \
190-
-e AWS_REGION="${{ secrets.AWS_REGION }}" \
191-
--rm -v "$PWD":/build "datasqrl/cmd:${SQRL_VERSION}" $cmd
229+
-e AWS_ACCESS_KEY_ID \
230+
-e AWS_SECRET_ACCESS_KEY \
231+
-e AWS_SESSION_TOKEN \
232+
-e AWS_REGION \
233+
-e AWS_DEFAULT_REGION \
234+
--rm -v "$PWD":/build "$SQRL_IMAGE" $cmd
192235
echo "::endgroup::"
193236
done
194237
195238
- name: Write Dockerfile
239+
if: steps.resolve-image.outputs.is_snapshot != 'true'
240+
env:
241+
SQRL_IMAGE: ${{ steps.resolve-image.outputs.image }}
196242
run: |
197243
cat <<EOF > ${{ matrix.path }}/Dockerfile
198-
FROM datasqrl/cmd:${SQRL_VERSION}
244+
FROM ${SQRL_IMAGE}
199245
200246
COPY . /build
201247
WORKDIR /build
202248
EOF
203249
204250
- name: Set up QEMU
251+
if: steps.resolve-image.outputs.is_snapshot != 'true'
205252
uses: docker/setup-qemu-action@v2
206253

207254
- name: Set up Docker Buildx
255+
if: steps.resolve-image.outputs.is_snapshot != 'true'
208256
uses: docker/setup-buildx-action@v2
209257

210258
- name: Login to Docker Hub
259+
if: steps.resolve-image.outputs.is_snapshot != 'true'
211260
uses: docker/login-action@v2
212261
with:
213262
username: ${{ secrets.DOCKER_USERNAME }}
214263
password: ${{ secrets.DOCKER_PASSWORD }}
215264

216265
- name: Publish ${{ matrix.example }}
266+
if: steps.resolve-image.outputs.is_snapshot != 'true'
217267
uses: docker/build-push-action@v3
218268
with:
219269
context: ./${{ matrix.path }}

0 commit comments

Comments
 (0)