mirror of https://github.com/garrytan/gstack.git
chore: self-bootstrapping CI — build Docker image inline, cache by content hash
Move Docker image build into the evals workflow as a dependency job. Image tag is keyed on hash of Dockerfile+lockfile+package.json — only rebuilds when those change. Eliminates chicken-and-egg problem where the image must exist before the first PR run. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a5c70977f1
commit
f1697f6678
|
|
@ -10,6 +10,13 @@ on:
|
||||||
- '.github/docker/Dockerfile.ci'
|
- '.github/docker/Dockerfile.ci'
|
||||||
- 'bun.lockb'
|
- 'bun.lockb'
|
||||||
- 'package.json'
|
- 'package.json'
|
||||||
|
# Build on PRs that change the image (so first PR run has it)
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
paths:
|
||||||
|
- '.github/docker/Dockerfile.ci'
|
||||||
|
- 'bun.lockb'
|
||||||
|
- 'package.json'
|
||||||
# Manual trigger
|
# Manual trigger
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,60 @@ concurrency:
|
||||||
group: evals-${{ github.head_ref }}
|
group: evals-${{ github.head_ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: ghcr.io/${{ github.repository }}/ci
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
# Build Docker image with pre-baked toolchain (cached — only rebuilds on Dockerfile/lockfile change)
|
||||||
|
build-image:
|
||||||
|
runs-on: ubicloud-standard-2
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
outputs:
|
||||||
|
image-tag: ${{ steps.meta.outputs.tag }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- id: meta
|
||||||
|
run: echo "tag=${{ env.IMAGE }}:${{ hashFiles('.github/docker/Dockerfile.ci', 'bun.lockb', 'package.json') }}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Check if image exists
|
||||||
|
id: check
|
||||||
|
run: |
|
||||||
|
if docker manifest inspect ${{ steps.meta.outputs.tag }} > /dev/null 2>&1; then
|
||||||
|
echo "exists=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "exists=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
DOCKER_CLI_EXPERIMENTAL: enabled
|
||||||
|
|
||||||
|
- if: steps.check.outputs.exists == 'false'
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ghcr.io
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- if: steps.check.outputs.exists == 'false'
|
||||||
|
run: cp bun.lockb package.json .github/docker/
|
||||||
|
|
||||||
|
- if: steps.check.outputs.exists == 'false'
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .github/docker
|
||||||
|
file: .github/docker/Dockerfile.ci
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ steps.meta.outputs.tag }}
|
||||||
|
${{ env.IMAGE }}:latest
|
||||||
|
|
||||||
evals:
|
evals:
|
||||||
runs-on: ubicloud-standard-2
|
runs-on: ubicloud-standard-2
|
||||||
|
needs: build-image
|
||||||
container:
|
container:
|
||||||
image: ghcr.io/${{ github.repository }}/ci:latest
|
image: ${{ needs.build-image.outputs.image-tag }}
|
||||||
credentials:
|
credentials:
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
@ -79,11 +128,6 @@ jobs:
|
||||||
|
|
||||||
report:
|
report:
|
||||||
runs-on: ubicloud-standard-2
|
runs-on: ubicloud-standard-2
|
||||||
container:
|
|
||||||
image: ghcr.io/${{ github.repository }}/ci:latest
|
|
||||||
credentials:
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
needs: evals
|
needs: evals
|
||||||
if: always() && github.event_name == 'pull_request'
|
if: always() && github.event_name == 'pull_request'
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue