-
Notifications
You must be signed in to change notification settings - Fork 3
193 lines (162 loc) · 6.39 KB
/
build-docker.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
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
name: Docker Image Build CI
on:
push:
# tags:
# - "v[0-9]+.[0-9]+.[0-9]+"
# branches:
# - main
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
web: ${{ steps.filter.outputs.web }}
processor: ${{ steps.filter.outputs.processor }}
attendance: ${{ steps.filter.outputs.attendance }}
chooser: ${{ steps.filter.outputs.chooser }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
web: 'apps/web/package.json'
processor: 'apps/processor/package.json'
attendance: 'apps/clients/attendance/package.json'
chooser: 'apps/clients/chooser/package.json'
web:
needs: changes
if: github.repository == 'sora-vp/baseline' && needs.changes.outputs.web == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build the Docker image
uses: docker/build-push-action@v5
with:
context: .
file: "./apps/web/Dockerfile"
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/sora-baseline-web:${{ github.ref_name }}
processor:
needs: changes
if: github.repository == 'sora-vp/baseline' && needs.changes.outputs.processor == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build the Docker image
uses: docker/build-push-action@v5
with:
context: .
file: "./apps/processor/Dockerfile"
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/sora-baseline-processor:${{ github.ref_name }}
client-attendance:
needs: changes
if: github.repository == 'sora-vp/baseline' && needs.changes.outputs.attendance == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build the Docker image
uses: docker/build-push-action@v5
with:
context: .
file: "./apps/clients/attendance/Dockerfile"
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/sora-baseline-client-attendance:${{ github.ref_name }}
client-chooser:
needs: changes
if: github.repository == 'sora-vp/baseline' && needs.changes.outputs.chooser == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build the Docker image
uses: docker/build-push-action@v5
with:
context: .
file: "./apps/clients/chooser/Dockerfile"
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/sora-baseline-client-chooser:${{ github.ref_name }}
update-docker-compose-repo:
needs: [web, processor, client-attendance, client-chooser]
if: |
always()
&& (contains(needs.web.result, 'success') || contains(needs.processor.result, 'success') || contains(needs.client-attendance.result, 'success') || contains(needs.client-chooser.result, 'success'))
&& !contains(needs.*.result, 'failure')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.BASIC_DOCKER_CONFIG_REPO_PAT }}
repository: sora-vp/baseline-docker
- name: setup git config
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: Rename version
env:
WEB_UPDATE: ${{ needs.web.result }}
PROCESSOR_UPDATE: ${{ needs.processor.result }}
ATTENDANCE_UPDATE: ${{ needs.client-attendance.result }}
CHOOSER_UPDATE: ${{ needs.client-chooser.result }}
REF_NAME: ${{ github.ref_name }}
run: |
echo "WEB_UPDATE: $WEB_UPDATE"
echo "PROCESSOR_UPDATE: $PROCESSOR_UPDATE"
echo "ATTENDANCE_UPDATE: $ATTENDANCE_UPDATE"
echo "CHOOSER_UPDATE: $CHOOSER_UPDATE"
if [ "$WEB_UPDATE" == "success" ]; then
sed -i 's/rmecha\/sora-baseline-web:[^ ]*/rmecha\/sora-baseline-web:'"$REF_NAME"'/' docker-compose.yml
fi
if [ "$PROCESSOR_UPDATE" == "success" ]; then
sed -i 's/rmecha\/sora-baseline-processor:[^ ]*/rmecha\/sora-baseline-processor:'"$REF_NAME"'/' docker-compose.yml
fi
if [ "$ATTENDANCE_UPDATE" == "success" ]; then
sed -i 's/rmecha\/sora-baseline-client-attendance:[^ ]*/rmecha\/sora-baseline-client-attendance:'"$REF_NAME"'/' docker-compose.yml
fi
if [ "$CHOOSER_UPDATE" == "success" ]; then
sed -i 's/rmecha\/sora-baseline-client-chooser:[^ ]*/rmecha\/sora-baseline-client-chooser:'"$REF_NAME"'/' docker-compose.yml
fi
- name: Commit changes
run: git commit -am "bot-update: update ${REF_NAME} | https://github.com/sora-vp/baseline/commit/${{ github.sha }}"
- name: Debug
run: git log
# - name: Push changes to basic docker compose config repository
# uses: cpina/github-action-push-to-another-repository@main
# env:
# API_TOKEN_GITHUB: ${{ secrets.BASIC_DOCKER_CONFIG_REPO_PAT }}
#
# with:
# destination-github-username: sora-vp
# destination-repository-name: baseline-docker
# create-target-branch-if-needed: true
# user-email: ${{ secrets.MAINTAINER_EMAIL }}
# target-branch: ${{ steps.extract_branch.outputs.branch }}