-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (58 loc) · 1.84 KB
/
build-images.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: "Build affected images on commit"
on:
push:
branches:
- master
paths:
- "apps/**"
- "!apps/**/README.md"
jobs:
get-changes:
name: Collect changes
runs-on: ubuntu-latest
outputs:
addedOrModifiedImages: ${{ steps.collect-changes.outputs.addedOrModifiedImages }}
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Collect changes
id: collect-changes
uses: ./.github/actions/collect-changes
generate-build-matrix:
name: Generate matrix for building images
runs-on: ubuntu-latest
needs: ["get-changes"]
outputs:
matrix: ${{ steps.get-changed.outputs.changes }}
if: ${{ needs.get-changes.outputs.addedOrModifiedImages }} != '[]'
steps:
- name: Install tools
run: sudo apt-get install moreutils jo
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
- name: Fetch modified images
id: get-changed
shell: bash
run: |
set -x
declare -a changes_array=()
while read -r app
do
while read -r build
do
change="$(jo app="$app" build="$build")"
changes_array+=($change)
done < <(yq -r '.builds[] | .name' "./apps/$app/.ci/metadata.yaml")
done < <(echo '${{ needs.get-changes.outputs.addedOrModifiedImages }}' | jq --raw-output -c '.[]')
output="$(jo -a ${changes_array[*]})"
echo "changes=${output}" >> $GITHUB_OUTPUT
images-build:
uses: ./.github/workflows/action-image-build.yaml
needs:
- generate-build-matrix
with:
imagesToBuild: "${{ needs.generate-build-matrix.outputs.matrix }}"
pushImages: "true"
secrets: inherit