Skip to content

Commit 450e19c

Browse files
committed
ci: update workflows
1 parent a2192bf commit 450e19c

File tree

2 files changed

+71
-2
lines changed

2 files changed

+71
-2
lines changed

.github/workflows/build-push.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Push Base Image
1+
name: Build and Push Images
22

33
on:
44
push:

.github/workflows/build.yml

+70-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build Base Image
1+
name: Build images
22

33
on:
44
pull_request:
@@ -24,6 +24,19 @@ jobs:
2424
id: set-matrix
2525
run: echo images="$(jq '."x-build"' base-images/src/*/.devcontainer.json | jq --slurp -c .)" >> "${GITHUB_OUTPUT}"
2626

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+
uses: actions/[email protected]
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+
2740
build:
2841
needs: prepare
2942
strategy:
@@ -76,3 +89,59 @@ jobs:
7689
--cache-from type=gha \
7790
--cache-to type=gha,mode=max
7891
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+
uses: actions/[email protected]
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

Comments
 (0)