-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (55 loc) · 1.89 KB
/
build-push.yml
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
name: build-push
on:
push:
jobs:
find-jobs:
name: Find changed directories
runs-on: ubuntu-latest
outputs:
folders: ${{ steps.jobs.outputs.folders }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: jobs
run: |
folders=$(git diff --diff-filter="ACMR" --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs dirname | awk -F '/' '{print $1}' | sort | uniq | grep -Ev "^\." | awk NF | jq -c --raw-input --slurp 'split("\n") | .[0:-1]')
echo $folders | jq .
echo "folders=$folders" >> $GITHUB_OUTPUT
get-tags:
needs: [find-jobs]
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.tags.outputs.tags }}
steps:
- uses: actions/checkout@v4
- id: tags
run: |
json_array=$(echo '${{ needs.find-jobs.outputs.folders }}' | jq -rc '.[]')
TAGS=$(while read -r REPO; do
if [ ! -d $REPO/.build-args ]; then
echo '{"context":"'${REPO}'", "image":"'${REPO}'", "args":""},'
continue
fi
for TAG in $(ls $REPO/.build-args); do
echo '{"context":"'${REPO}'", "image":"'${REPO}'-'${TAG}'", "args":"'$(cat ${REPO}/.build-args/${TAG})'"},'
done
done <<< "$json_array")
TAGS=$(echo "[${TAGS%,}]" | tr -d '\n')
echo $TAGS | jq .
echo "tags=$TAGS" >> $GITHUB_OUTPUT
build-push-ar:
name: "Build and push ${{ matrix.tags.image }} to Google Artifact Registry"
needs: [get-tags]
strategy:
matrix:
tags: ${{ fromJson(needs.get-tags.outputs.tags) }}
uses: ./.github/workflows/build-push-ar.yml
with:
image: "internal/${{ matrix.tags.image }}"
context: ${{ matrix.tags.context }}
build-args: ${{ matrix.tags.args }}
permissions:
contents: read
id-token: write
secrets: inherit