|
8 | 8 | schedule: |
9 | 9 | - cron: '0 11 * * *' |
10 | 10 | workflow_dispatch: |
11 | | - inputs: |
12 | | - no-cache: |
13 | | - description: 'Full rebuild without Docker cache' |
14 | | - type: boolean |
15 | | - default: false |
16 | 11 |
|
17 | 12 | permissions: |
18 | 13 | contents: read |
19 | 14 | packages: write |
20 | | - attestations: write |
21 | 15 | id-token: write |
22 | 16 |
|
23 | | -env: |
24 | | - REGISTRY: ghcr.io |
25 | | - |
26 | 17 | concurrency: |
27 | 18 | group: build-claude-code-${{ github.ref }} |
28 | 19 | cancel-in-progress: true |
29 | 20 |
|
30 | 21 | jobs: |
31 | | - build-and-push: |
32 | | - name: Build & Push (${{ matrix.target }}) |
33 | | - runs-on: ubuntu-24.04 |
| 22 | + build-default: |
| 23 | + uses: docker/github-builder/.github/workflows/build.yml@v1 |
| 24 | + permissions: |
| 25 | + contents: read |
| 26 | + packages: write |
| 27 | + id-token: write |
| 28 | + with: |
| 29 | + output: image |
| 30 | + push: true |
| 31 | + target: default |
| 32 | + context: claude-code/.devcontainer |
| 33 | + file: claude-code/.devcontainer/Dockerfile |
| 34 | + platforms: linux/amd64,linux/arm64 |
| 35 | + meta-images: ghcr.io/gatezh/devcontainer-images/claude-code |
| 36 | + meta-tags: | |
| 37 | + type=raw,value=latest |
| 38 | + type=sha,prefix= |
| 39 | + type=raw,value={{date 'YYYYMMDD'}} |
| 40 | + secrets: |
| 41 | + registry-auths: | |
| 42 | + - registry: ghcr.io |
| 43 | + username: ${{ github.actor }} |
| 44 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 45 | +
|
| 46 | + build-sandbox: |
| 47 | + uses: docker/github-builder/.github/workflows/build.yml@v1 |
| 48 | + permissions: |
| 49 | + contents: read |
| 50 | + packages: write |
| 51 | + id-token: write |
| 52 | + with: |
| 53 | + output: image |
| 54 | + push: true |
| 55 | + target: sandbox |
| 56 | + context: claude-code/.devcontainer |
| 57 | + file: claude-code/.devcontainer/Dockerfile |
| 58 | + platforms: linux/amd64,linux/arm64 |
| 59 | + meta-images: ghcr.io/gatezh/devcontainer-images/claude-code-sandbox |
| 60 | + meta-tags: | |
| 61 | + type=raw,value=latest |
| 62 | + type=sha,prefix= |
| 63 | + type=raw,value={{date 'YYYYMMDD'}} |
| 64 | + secrets: |
| 65 | + registry-auths: | |
| 66 | + - registry: ghcr.io |
| 67 | + username: ${{ github.actor }} |
| 68 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 69 | +
|
| 70 | + verify: |
| 71 | + name: Verify ${{ matrix.image-suffix }} (${{ matrix.arch }}) |
| 72 | + needs: [build-default, build-sandbox] |
34 | 73 | strategy: |
| 74 | + fail-fast: false |
35 | 75 | matrix: |
36 | 76 | include: |
37 | | - - target: default |
38 | | - image-suffix: claude-code |
| 77 | + - image-suffix: claude-code |
| 78 | + verify-command: "bun --version || true && claude --version && mise --version && fish --version" |
| 79 | + runner: ubuntu-24.04 |
| 80 | + arch: amd64 |
| 81 | + - image-suffix: claude-code |
39 | 82 | verify-command: "bun --version || true && claude --version && mise --version && fish --version" |
40 | | - - target: sandbox |
41 | | - image-suffix: claude-code-sandbox |
| 83 | + runner: ubuntu-24.04-arm |
| 84 | + arch: arm64 |
| 85 | + - image-suffix: claude-code-sandbox |
| 86 | + verify-command: "claude --version && mise --version && fish --version && which iptables" |
| 87 | + runner: ubuntu-24.04 |
| 88 | + arch: amd64 |
| 89 | + - image-suffix: claude-code-sandbox |
42 | 90 | verify-command: "claude --version && mise --version && fish --version && which iptables" |
| 91 | + runner: ubuntu-24.04-arm |
| 92 | + arch: arm64 |
| 93 | + runs-on: ${{ matrix.runner }} |
43 | 94 | steps: |
44 | | - - uses: actions/checkout@v6 |
45 | | - |
46 | | - - name: Lowercase image base |
47 | | - id: repo |
48 | | - run: echo "image_base=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" |
49 | | - |
50 | | - - name: Set up QEMU |
51 | | - uses: docker/setup-qemu-action@v4 |
52 | | - |
53 | | - - name: Set up Docker Buildx |
54 | | - uses: docker/setup-buildx-action@v4 |
55 | | - |
56 | 95 | - name: Log in to GHCR |
57 | 96 | uses: docker/login-action@v4 |
58 | 97 | with: |
59 | | - registry: ${{ env.REGISTRY }} |
| 98 | + registry: ghcr.io |
60 | 99 | username: ${{ github.actor }} |
61 | 100 | password: ${{ secrets.GITHUB_TOKEN }} |
62 | 101 |
|
63 | | - - name: Extract metadata (tags, labels) |
64 | | - id: meta |
65 | | - uses: docker/metadata-action@v6 |
66 | | - with: |
67 | | - images: ${{ steps.repo.outputs.image_base }}/${{ matrix.image-suffix }} |
68 | | - tags: | |
69 | | - type=raw,value=latest |
70 | | - type=sha,prefix= |
71 | | - type=raw,value={{date 'YYYYMMDD'}} |
72 | | -
|
73 | | - - name: Build and push |
74 | | - id: push |
75 | | - uses: docker/build-push-action@v7 |
76 | | - with: |
77 | | - context: claude-code/.devcontainer |
78 | | - file: claude-code/.devcontainer/Dockerfile |
79 | | - target: ${{ matrix.target }} |
80 | | - platforms: linux/amd64,linux/arm64 |
81 | | - push: true |
82 | | - tags: ${{ steps.meta.outputs.tags }} |
83 | | - labels: ${{ steps.meta.outputs.labels }} |
84 | | - build-args: | |
85 | | - CACHE_BUST=${{ github.event_name != 'push' && github.run_id || 'stable' }} |
86 | | - no-cache: ${{ inputs.no-cache == true }} |
87 | | - cache-from: type=gha,scope=${{ matrix.target }} |
88 | | - cache-to: type=gha,mode=max,scope=${{ matrix.target }} |
89 | | - |
90 | | - - name: Generate artifact attestation |
91 | | - uses: actions/attest@v4 |
92 | | - with: |
93 | | - subject-name: ${{ steps.repo.outputs.image_base }}/${{ matrix.image-suffix }} |
94 | | - subject-digest: ${{ steps.push.outputs.digest }} |
95 | | - push-to-registry: true |
96 | | - |
97 | | - - name: Verify image (amd64) |
98 | | - run: | |
99 | | - docker pull --platform linux/amd64 ${{ steps.repo.outputs.image_base }}/${{ matrix.image-suffix }}:latest |
100 | | - docker run --rm --platform linux/amd64 ${{ steps.repo.outputs.image_base }}/${{ matrix.image-suffix }}:latest bash -c "${{ matrix.verify-command }}" |
101 | | -
|
102 | | - - name: Verify image (arm64) |
| 102 | + - name: Verify image |
103 | 103 | run: | |
104 | | - docker pull --platform linux/arm64 ${{ steps.repo.outputs.image_base }}/${{ matrix.image-suffix }}:latest |
105 | | - docker run --rm --platform linux/arm64 ${{ steps.repo.outputs.image_base }}/${{ matrix.image-suffix }}:latest bash -c "${{ matrix.verify-command }}" |
| 104 | + docker pull ghcr.io/gatezh/devcontainer-images/${{ matrix.image-suffix }}:latest |
| 105 | + docker run --rm ghcr.io/gatezh/devcontainer-images/${{ matrix.image-suffix }}:latest bash -c "${{ matrix.verify-command }}" |
0 commit comments