-
Notifications
You must be signed in to change notification settings - Fork 9
249 lines (238 loc) · 10 KB
/
integration.yaml
File metadata and controls
249 lines (238 loc) · 10 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: Integration
on:
pull_request:
types:
- opened
- closed
- reopened
- synchronize
workflow_dispatch:
jobs:
test:
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
platform: linux/amd64
- runner: ubuntu-24.04-arm
platform: linux/arm64
runs-on: ${{ matrix.runner }}
steps:
- name: Set environment variables
run: |
# TODO: Delete it once you have completed the migration from CircleCI.
echo "CIRCLE_BUILD_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV
echo "GITHUB_JOB_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV
echo "CHATWORK_API_TOKEN=${{ secrets.CHATWORK_API_TOKEN }}" >> $GITHUB_ENV
echo "CHATWORK_NOTIFICATION_ROOM_ID=${{ secrets.CHATWORK_NOTIFICATION_ROOM_ID }}" >> $GITHUB_ENV
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Login to Docker Hub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.CW_DOCKER_HUB_USERNAME }}
password: ${{ secrets.CW_DOCKER_HUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
with:
image: tonistiigi/binfmt:qemu-v7.0.0-28
platforms: linux/amd64,linux/arm64
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
# TODO: Replace docker-compose in each Makefile and then delete it.
- name: Add docker-compose
run: |
mkdir -p /home/runner/.local/bin
cat << EOT >> /home/runner/.local/bin/docker-compose
#!/bin/bash
docker compose "\$@"
EOT
chmod +x /home/runner/.local/bin/docker-compose
- run: make ci:diff
- run: |
ARCH=`make arch`
EXTENSION=`make extension`
echo ARCH: "${ARCH}"
echo EXTENSION: "${EXTENSION}"
make ci:diff | while read DIR; do
cd ${GITHUB_WORKSPACE}/${DIR}
if find . -type l -o -type f -name "Dockerfile${EXTENSION}" | grep Dockerfile ; then
make build;
make test;
else
echo "${DIR} is ${ARCH} not supported. make build & make test was skipped.";
fi
done
- name: Notification failed
if: failure() && github.actor == 'cw-circleci'
run: |
make ci:notify -e TITLE="Github Actions: Failed to CI of PR created by automatic update of dependency (devil) arch: $(make arch)" \
-e BODY="${{ github.event.pull_request.html_url }}"
push:
if: github.ref_name == 'master'
needs: test
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
platform: linux/amd64
- runner: ubuntu-24.04-arm
platform: linux/arm64
runs-on: ${{ matrix.runner }}
steps:
- name: Set environment variables
run: |
# TODO: Delete it once you have completed the migration from CircleCI.
echo "CIRCLE_BUILD_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV
echo "GITHUB_JOB_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV
echo "CHATWORK_API_TOKEN=${{ secrets.CHATWORK_API_TOKEN }}" >> $GITHUB_ENV
echo "CHATWORK_NOTIFICATION_ROOM_ID=${{ secrets.CHATWORK_NOTIFICATION_ROOM_ID }}" >> $GITHUB_ENV
- run: echo ${{ github.head_ref }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Login to Docker Hub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.CW_DOCKER_HUB_USERNAME }}
password: ${{ secrets.CW_DOCKER_HUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
with:
image: tonistiigi/binfmt:qemu-v7.0.0-28
platforms: linux/amd64,linux/arm64
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
# TODO: Replace docker-compose in each Makefile and then delete it.
- name: Add docker-compose
run: |
mkdir -p /home/runner/.local/bin
cat << EOT >> /home/runner/.local/bin/docker-compose
#!/bin/bash
docker compose "\$@"
EOT
chmod +x /home/runner/.local/bin/docker-compose
- run: make ci:diff
- name: Build
run: |
ARCH=`make arch`
EXTENSION=`make extension`
make ci:diff | while read DIR; do
cd ${GITHUB_WORKSPACE}/${DIR}
if find . -type l -o -type f -name "Dockerfile${EXTENSION}" | grep Dockerfile ; then
make build;
else
echo "${DIR} is ${ARCH} not supported. make build & make test was skipped.";
fi
done
- name: Push
run: |
ARCH=`make arch`
EXTENSION=`make extension`
make ci:diff | while read DIR; do
cd ${GITHUB_WORKSPACE}/${DIR}
if find . -type l -o -type f -name "Dockerfile${EXTENSION}" | grep Dockerfile ; then
make push;
else
echo "${DIR} is ${ARCH} not supported. make build & make test was skipped.";
fi
done
- name: Notification failed
if: failure()
run: |
ARCH=`make arch`
EXTENSION=`make extension`
make ci:diff | while read DIR; do
if find ./${DIR} -type l -o -type f -name "Dockerfile${EXTENSION}" | grep Dockerfile ; then
make ci:notify -e TITLE="Github Actions: Failed push chatwork/${DIR} arch: $(make arch) (devil)" \
-e BODY="$(git log -1 --pretty=format:"%h - %an : %s")";
else
echo "chatwork/${DIR} is ${ARCH} not supported. docker push was skipped.";
fi
done
- name: Notification success
if: success()
run: |
ARCH=`make arch`
EXTENSION=`make extension`
make ci:diff | while read DIR; do
if find ./${DIR} -type l -o -type f -name "Dockerfile${EXTENSION}" | grep Dockerfile ; then
version=$(docker inspect -f {{.Config.Labels.version}} chatwork/${DIR});
echo "version: ${version}"
changelog=$(make ci:changelog -e DIR="${DIR}/");
echo "changelog: ${changelog}"
make ci:notify -e TITLE="Release chatwork/${DIR}:${version} arch: $(make arch) (gogo)" \
-e BODY="$(echo -e "changelog\n${changelog}")";
else
echo "chatwork/${DIR} is ${ARCH} not supported. docker push was skipped.";
fi
done
manifest:
if: github.ref_name == 'master'
needs:
- test
- push
runs-on: ubuntu-latest
steps:
- name: Set environment variables
run: |
# TODO: Delete it once you have completed the migration from CircleCI.
echo "CIRCLE_BUILD_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV
echo "GITHUB_JOB_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_ENV
echo "CHATWORK_API_TOKEN=${{ secrets.CHATWORK_API_TOKEN }}" >> $GITHUB_ENV
echo "CHATWORK_NOTIFICATION_ROOM_ID=${{ secrets.CHATWORK_NOTIFICATION_ROOM_ID }}" >> $GITHUB_ENV
- run: echo ${{ github.head_ref }}
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Login to Docker Hub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.CW_DOCKER_HUB_USERNAME }}
password: ${{ secrets.CW_DOCKER_HUB_TOKEN }}
- uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- run: make ci:diff
- name: Install hub-tool
run: |
sudo apt-get update
sudo apt-get install -y expect
curl -OL https://github.com/docker/hub-tool/releases/download/v0.4.3/hub-tool-linux-amd64.tar.gz
tar xvf hub-tool-linux-amd64.tar.gz
sudo mv ./hub-tool/hub-tool /usr/local/bin
expect -c "
set timeout 5
spawn env hub-tool login ${{ secrets.CW_DOCKER_HUB_USERNAME }}
expect \"Password:\"
send \"${{ secrets.CW_DOCKER_HUB_TOKEN }}\n\"
expect \"$\"
exit 0
"
hub-tool version
- name: Update manifest
run: |
make ci:diff
make ci:diff | while read DIR; do
if [ -e "$GITHUB_WORKSPACE/$DIR/Dockerfile.arm64" ] && [ -e "$GITHUB_WORKSPACE/$DIR/Dockerfile" ] && [ ! -L "$GITHUB_WORKSPACE/$DIR/Dockerfile.arm64" ]; then
cd ${GITHUB_WORKSPACE}/${DIR};
make build;
make manifest:push;
else
echo "skip manifest job"
fi
done
- name: Notification failed
if: failure()
run: |
make ci:notify -e TITLE="CircleCI: Failed manifest (devil)" \
-e BODY="$(git log -1 --pretty=format:"%h - %an : %s")";
- name: Notification success
if: success()
run: |
make ci:diff | while read DIR; do
if [ -e "$GITHUB_WORKSPACE/$DIR/Dockerfile.arm64" ] && [ -e "$GITHUB_WORKSPACE/$DIR/Dockerfile" ] && [ ! -L "$GITHUB_WORKSPACE/$DIR/Dockerfile.arm64" ]; then
version=$(docker inspect -f {{.Config.Labels.version}} chatwork/${DIR});
make ci:notify -e TITLE="manifest succeeded chatwork/${DIR}:${version} (gogo)" \
-e BODY="$(make manifest:succeed-message -f ${GITHUB_WORKSPACE}/${DIR}/Makefile)";
fi
done