|
1 |
| -name: Build Base Image |
| 1 | +name: Build images |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | pull_request:
|
|
24 | 24 | id: set-matrix
|
25 | 25 | run: echo images="$(jq '."x-build"' base-images/src/*/.devcontainer.json | jq --slurp -c .)" >> "${GITHUB_OUTPUT}"
|
26 | 26 |
|
| 27 | + prepare-others: |
| 28 | + name: Prepare list of other images to build |
| 29 | + runs-on: ubuntu-latest |
| 30 | + outputs: |
| 31 | + images: ${{ steps.set-matrix.outputs.images }} |
| 32 | + steps: |
| 33 | + - name: Check out the source code |
| 34 | + |
| 35 | + |
| 36 | + - name: Set matrix |
| 37 | + id: set-matrix |
| 38 | + run: echo images="$(jq '."x-build"' images/src/*/.devcontainer.json | jq --slurp -c .)" >> "${GITHUB_OUTPUT}" |
| 39 | + |
27 | 40 | build:
|
28 | 41 | needs: prepare
|
29 | 42 | strategy:
|
|
76 | 89 | --cache-from type=gha \
|
77 | 90 | --cache-to type=gha,mode=max
|
78 | 91 | if: steps.changes.outputs.needs_build == 'true'
|
| 92 | + |
| 93 | + build-other-images: |
| 94 | + needs: |
| 95 | + - prepare-others |
| 96 | + name: 'Build image ${{ matrix.image.name }}' |
| 97 | + runs-on: ubuntu-latest |
| 98 | + permissions: |
| 99 | + contents: read |
| 100 | + packages: write |
| 101 | + strategy: |
| 102 | + fail-fast: false |
| 103 | + matrix: |
| 104 | + image: ${{ fromJson(needs.prepare-others.outputs.images) }} |
| 105 | + steps: |
| 106 | + - name: Check out the repo |
| 107 | + |
| 108 | + with: |
| 109 | + fetch-depth: 0 |
| 110 | + |
| 111 | + - name: Check changed files |
| 112 | + id: changes |
| 113 | + run: | |
| 114 | + base="${{ github.event.pull_request.base.sha }}" |
| 115 | + head="${{ github.event.pull_request.head.sha }}" |
| 116 | + image="images/src/${{ matrix.image.image-name }}" |
| 117 | + changes="$(git diff --name-only "${base}" "${head}" -- "${image}" | grep -Fv "${image}/README.md" || true)" |
| 118 | + if [ -n "${changes}" ]; then |
| 119 | + echo needs_build=true >> "${GITHUB_OUTPUT}" |
| 120 | + else |
| 121 | + echo needs_build=false >> "${GITHUB_OUTPUT}" |
| 122 | + fi |
| 123 | +
|
| 124 | + - name: Expose GitHub Runtime |
| 125 | + uses: Automattic/vip-actions/expose-github-runtime@e1faabf165941008de4c0c1381df153e49d8ad2c # v0.6.0 |
| 126 | + |
| 127 | + - name: Set up QEMU |
| 128 | + uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 |
| 129 | + if: steps.changes.outputs.needs_build == 'true' |
| 130 | + |
| 131 | + - name: Set up Docker Buildx |
| 132 | + uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 |
| 133 | + if: steps.changes.outputs.needs_build == 'true' |
| 134 | + |
| 135 | + - name: Install @devcontainers/cli |
| 136 | + run: npm install -g @devcontainers/cli |
| 137 | + if: ${{ steps.changes.outputs.needs_build == 'true' }} |
| 138 | + |
| 139 | + - name: Build image |
| 140 | + run: | |
| 141 | + devcontainer build \ |
| 142 | + --workspace-folder images/src/${{ matrix.image.image-name }} \ |
| 143 | + --platform linux/amd64,linux/arm64 \ |
| 144 | + --output type=image \ |
| 145 | + --cache-from type=gha \ |
| 146 | + --cache-to type=gha,mode=max |
| 147 | + if: ${{ steps.changes.outputs.needs_build == 'true' }} |
0 commit comments