-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (55 loc) · 2.04 KB
/
prepare-matrix.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
# yamllint disable rule:comments
---
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Prepare matrix of changed images
'on':
workflow_call:
outputs:
matrix:
description: "Matrix of images to build"
value: ${{ jobs.prepare-matrix.outputs.matrix }}
jobs:
prepare-matrix:
name: Prepare matrix of images to build
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Generate Token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
id: generate-token
with:
app_id: "${{ secrets.BOT_APP_ID }}"
private_key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: "${{ steps.generate-token.outputs.token }}"
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@bab30c2299617f6615ec02a68b9a40d10bd21366 # v45.0.5
- name: Setup matrix
id: set-matrix
run: |
apps=" "
# shellcheck disable=SC2043
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [[ "${file}" == "apps/"* ]] && [[ "${file}" != *".md" ]]; then
app="$(sed -E 's@apps/([^/]+).*@\1@g' <<< "${file}")"
if [[ ! "${apps}" == *" ${app} "* ]]; then
apps="${apps}${app} "
fi
fi
done
matrix="["
# shellcheck disable=SC2086,SC2116
for app in $(echo "${apps}"); do
# shellcheck disable=SC2086
for channel in $(jq --raw-output '.channels | .[] | .name' apps/${app}/metadata.json); do
matrix="${matrix}{\"app\":\"${app}\",\"channel\":\"${channel}\"},"
done
done
matrix="${matrix}]"
sed -E 's@,\]@]@g' <<< "matrix=${matrix}" >> "$GITHUB_OUTPUT"
# yamllint enable rule:comments