-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (123 loc) · 4.29 KB
/
build.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Image Building
on:
push:
branches:
- "main"
paths:
- "containers/**"
- ".github/workflows/**"
jobs:
generate-matrix:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Calculate file differences
id: diff
uses: tj-actions/changed-files@da093c1609db0edd0a037ce9664e135f74bf30d9 # v40.2.0
with:
files_yaml: |
containers:
- containers/**
workflows:
- ./.github/workflows/**
- name: Generate Matrix
id: matrix
run: |
base_changed=false
docker_changed=false
go_changed=false
node_changed=false
sysdig_changed=false
for path in ${{steps.diff.outputs.workflows_all_changed_and_modified_files}}; do
filename=$(basename "${path}")
case ${filename%.*} in
build-base)
base_changed=true
;;
build-docker)
docker_changed=true
;;
build-go)
go_changed=true
;;
build-node)
node_changed=true
;;
build-sysdig)
sysdig_changed=true
;;
esac
done
for path in ${{steps.diff.outputs.containers_all_changed_and_modified_files}}; do
foldername=$(echo $path | cut -d / -f 2)
case ${foldername%.*} in
base)
base_changed=true
;;
docker)
docker_changed=true
;;
go)
go_changed=true
;;
node)
node_changed=true
;;
sysdig)
sysdig_changed=true
;;
esac
done
echo "base_changed=${base_changed}" >> $GITHUB_OUTPUT
echo "docker_changed=${docker_changed}" >> $GITHUB_OUTPUT
echo "go_changed=${go_changed}" >> $GITHUB_OUTPUT
echo "node_changed=${node_changed}" >> $GITHUB_OUTPUT
echo "sysdig_changed=${sysdig_changed}" >> $GITHUB_OUTPUT
outputs:
base_changed: ${{ steps.matrix.outputs.base_changed }}
docker_changed: ${{ steps.matrix.outputs.docker_changed }}
go_changed: ${{ steps.matrix.outputs.go_changed }}
node_changed: ${{ steps.matrix.outputs.node_changed }}
sysdig_changed: ${{ steps.matrix.outputs.sysdig_changed }}
rebuild-base:
needs: generate-matrix
if: needs.generate-matrix.outputs.base_changed == 'true'
uses: ./.github/workflows/build-base.yml
secrets: inherit
rebuild-docker:
needs: generate-matrix
if: needs.generate-matrix.outputs.base_changed == 'false' && needs.generate-matrix.outputs.docker_changed == 'true'
uses: ./.github/workflows/build-docker.yml
secrets:
BOT_DOCKER_USERNAME: ${{ secrets.BOT_DOCKER_USERNAME }}
BOT_DOCKER_TOKEN: ${{ secrets.BOT_DOCKER_TOKEN }}
BOT_USER: ${{ secrets.BOT_USER }}
BOT_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
rebuild-go:
needs: generate-matrix
if: needs.generate-matrix.outputs.base_changed == 'false' && needs.generate-matrix.outputs.go_changed == 'true'
uses: ./.github/workflows/build-go.yml
secrets:
BOT_DOCKER_USERNAME: ${{ secrets.BOT_DOCKER_USERNAME }}
BOT_DOCKER_TOKEN: ${{ secrets.BOT_DOCKER_TOKEN }}
BOT_USER: ${{ secrets.BOT_USER }}
BOT_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
rebuild-node:
needs: generate-matrix
if: needs.generate-matrix.outputs.base_changed == 'false' && needs.generate-matrix.outputs.node_changed == 'true'
uses: ./.github/workflows/build-node.yml
secrets:
BOT_DOCKER_USERNAME: ${{ secrets.BOT_DOCKER_USERNAME }}
BOT_DOCKER_TOKEN: ${{ secrets.BOT_DOCKER_TOKEN }}
BOT_USER: ${{ secrets.BOT_USER }}
BOT_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
rebuild-sysdig:
needs: generate-matrix
if: needs.generate-matrix.outputs.base_changed == 'false' && needs.generate-matrix.outputs.sysdig_changed == 'true'
uses: ./.github/workflows/build-sysdig.yml
secrets:
BOT_DOCKER_USERNAME: ${{ secrets.BOT_DOCKER_USERNAME }}
BOT_DOCKER_TOKEN: ${{ secrets.BOT_DOCKER_TOKEN }}
BOT_USER: ${{ secrets.BOT_USER }}
BOT_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}