-
Notifications
You must be signed in to change notification settings - Fork 2
216 lines (165 loc) · 5.35 KB
/
main.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
name: docker publish
on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main
release:
types:
- created
- edited
- prereleased
- published
- released
jobs:
build-django:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build django image
run: |
docker build . --file docker/Dockerfile --tag b3lb
docker save b3lb > /tmp/b3lb.tar
- name: Upload django artifact
uses: actions/upload-artifact@v2
with:
name: b3lb
path: /tmp/b3lb.tar
build-pypy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build django image
run: |
docker build . --file docker/Dockerfile.pypy --tag b3lb-pypy
docker save b3lb-pypy > /tmp/b3lb-pypy.tar
- name: Upload django artifact
uses: actions/upload-artifact@v2
with:
name: b3lb-pypy
path: /tmp/b3lb-pypy.tar
build-render:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build render image
run: |
docker build . --file docker/Dockerfile.render --tag b3lb-render
docker save b3lb-render > /tmp/b3lb-render.tar
- name: Upload django artifact
uses: actions/upload-artifact@v2
with:
name: b3lb-render
path: /tmp/b3lb-render.tar
build-static:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build static image
run: |
docker build . --file docker/Dockerfile.static --tag b3lb-static
docker save b3lb-static > /tmp/b3lb-static.tar
- name: Upload static artifact
uses: actions/upload-artifact@v2
with:
name: b3lb-static
path: /tmp/b3lb-static.tar
build-dev:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build dev image
run: |
docker build . --file docker/Dockerfile.dev --tag b3lb-dev
docker save b3lb-dev > /tmp/b3lb-dev.tar
- name: Upload dev artifact
uses: actions/upload-artifact@v2
with:
name: b3lb-dev
path: /tmp/b3lb-dev.tar
push-latest:
needs: build-dev
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: b3lb-dev
path: /tmp
- name: Push images
run: |
docker load < /tmp/b3lb-dev.tar
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo IMAGE_ID =$IMAGE_ID
echo IMAGE_TAG=latest
docker tag b3lb-dev $IMAGE_ID/b3lb-dev:latest
docker push $IMAGE_ID/b3lb-dev:latest
push-release:
needs: ["build-django", "build-pypy", "build-dev", "build-static", "build-render"]
runs-on: ubuntu-latest
if: github.event_name == 'release'
steps:
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Download django artifact
uses: actions/download-artifact@v2
with:
name: b3lb
path: /tmp
- name: Download django pypy artifact
uses: actions/download-artifact@v2
with:
name: b3lb-pypy
path: /tmp
- name: Download render artifact
uses: actions/download-artifact@v2
with:
name: b3lb-render
path: /tmp
- name: Download dev artifact
uses: actions/download-artifact@v2
with:
name: b3lb-dev
path: /tmp
- name: Download static artifact
uses: actions/download-artifact@v2
with:
name: b3lb-static
path: /tmp
- name: Push images
run: |
docker load < /tmp/b3lb.tar
docker load < /tmp/b3lb-pypy.tar
docker load < /tmp/b3lb-render.tar
docker load < /tmp/b3lb-dev.tar
docker load < /tmp/b3lb-static.tar
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
echo IMAGE_ID =$IMAGE_ID
echo IMAGE_TAG=latest
docker tag b3lb $IMAGE_ID/b3lb:$VERSION
docker tag b3lb-pypy $IMAGE_ID/b3lb-pypy:$VERSION
docker tag b3lb-render $IMAGE_ID/b3lb-render:$VERSION
docker tag b3lb-dev $IMAGE_ID/b3lb-dev:$VERSION
docker tag b3lb-static $IMAGE_ID/b3lb-static:$VERSION
docker push $IMAGE_ID/b3lb:$VERSION
docker push $IMAGE_ID/b3lb-pypy:$VERSION
docker push $IMAGE_ID/b3lb-render:$VERSION
docker push $IMAGE_ID/b3lb-dev:$VERSION
docker push $IMAGE_ID/b3lb-static:$VERSION