-
Notifications
You must be signed in to change notification settings - Fork 0
267 lines (256 loc) · 10.1 KB
/
publish.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
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
name: publish
on:
#repository_dispatch:
# types: [trigger-ocelot-build-success]
push:
branches:
- master
jobs:
build_branded:
name: Docker Build Branded
runs-on: ubuntu-latest
env:
SECRET: ${{ secrets.SECRET }}
CONFIGURATION: "this"
GITHUB_OCELOT_REF_JUST_BUILT: ${{ github.event.client_payload.ref }}
OCELOT_GITHUB_RUN_NUMBER: ${{ github.event.client_payload.GITHUB_RUN_NUMBER }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Decrypt .env
run: gpg --quiet --batch --yes --decrypt --passphrase="${{ env.SECRET }}" --output .env .env.enc
- name: Load .env
uses: aarcangeli/[email protected]
with:
quiet: true
- name: Set GITHUB_OCELOT_REF
run: |
if [ -z ${GITHUB_OCELOT_REF} ]; then
echo "GITHUB_OCELOT_REF=${GITHUB_OCELOT_REF_JUST_BUILT}" >> $GITHUB_ENV
fi
shell: bash
- name: Set DOCKERHUB_ORGANISATION
run: |
if [ -z ${DOCKERHUB_ORGANISATION} ]; then
echo "DOCKERHUB_ORGANISATION=ocelotsocialnetwork" >> $GITHUB_ENV
fi
- name: Checkout Ocelot code
uses: actions/checkout@v3
with:
repository: 'Ocelot-Social-Community/Ocelot-Social'
ref: ${{ env.GITHUB_OCELOT_REF }}
path: 'ocelot/'
fetch-depth: 0
- name: Set OCELOT_GITHUB_RUN_NUMBER
run: |
if [ -z ${OCELOT_GITHUB_RUN_NUMBER} ]; then
echo "OCELOT_GITHUB_RUN_NUMBER=${GITHUB_OCELOT_REF}" >> $GITHUB_ENV
fi
if [ -z ${OCELOT_GITHUB_RUN_NUMBER} ]; then
echo "OCELOT_GITHUB_RUN_NUMBER=master" >> $GITHUB_ENV
fi
shell: bash
- name: Checkout Branded Repo code
uses: actions/checkout@v3
with:
ref: 'master'
path: "ocelot/deployment/configurations/${{ env.CONFIGURATION }}"
fetch-depth: 0
- name: Build branded images
run: |
ocelot/deployment/scripts/branded-images.build.sh
docker save "${DOCKERHUB_ORGANISATION}/backend-${DOCKERHUB_BRAND_VARRIANT}" > /tmp/backend-branded.tar
docker save "${DOCKERHUB_ORGANISATION}/webapp-${DOCKERHUB_BRAND_VARRIANT}" > /tmp/webapp-branded.tar
docker save "${DOCKERHUB_ORGANISATION}/maintenance-${DOCKERHUB_BRAND_VARRIANT}" > /tmp/maintenance-branded.tar
- name: Upload Artifact (Backend)
uses: actions/upload-artifact@v2
with:
name: docker-backend-branded
path: /tmp/backend-branded.tar
- name: Upload Artifact (Webapp)
uses: actions/upload-artifact@v2
with:
name: docker-webapp-branded
path: /tmp/webapp-branded.tar
- name: Upload Artifact (Maintenance)
uses: actions/upload-artifact@v2
with:
name: docker-maintenance-branded
path: /tmp/maintenance-branded.tar
upload_to_dockerhub:
name: Upload to Dockerhub
runs-on: ubuntu-latest
needs: [build_branded]
env:
SECRET: ${{ secrets.SECRET }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
GITHUB_OCELOT_REF_JUST_BUILT: ${{ github.event.client_payload.ref }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Decrypt .env
run: gpg --quiet --batch --yes --decrypt --passphrase="${{ env.SECRET }}" --output .env .env.enc
- name: Load .env
uses: aarcangeli/[email protected]
with:
quiet: true
- name: Set GITHUB_OCELOT_REF
run: |
if [ -z ${GITHUB_OCELOT_REF} ]; then
echo "GITHUB_OCELOT_REF=${GITHUB_OCELOT_REF_JUST_BUILT}" >> $GITHUB_ENV
fi
shell: bash
- name: Checkout Ocelot code
uses: actions/checkout@v3
with:
repository: 'Ocelot-Social-Community/Ocelot-Social'
ref: ${{ env.GITHUB_OCELOT_REF }}
path: 'ocelot/'
fetch-depth: 0
- name: Download Docker Image (Backend)
uses: actions/download-artifact@v2
with:
name: docker-backend-branded
path: /tmp
- name: Load Docker Image
run: docker load < /tmp/backend-branded.tar
- name: Download Docker Image (Webapp)
uses: actions/download-artifact@v2
with:
name: docker-webapp-branded
path: /tmp
- name: Load Docker Image
run: docker load < /tmp/webapp-branded.tar
- name: Download Docker Image (Maintenance)
uses: actions/download-artifact@v2
with:
name: docker-maintenance-branded
path: /tmp
- name: Load Docker Image
run: docker load < /tmp/maintenance-branded.tar
- name: Upload to dockerhub
run: ocelot/deployment/scripts/branded-images.upload.sh
github_tag:
name: Tag latest version on Github
runs-on: ubuntu-latest
needs: [upload_to_dockerhub]
env:
SECRET: ${{ secrets.SECRET }}
GITHUB_OCELOT_REF_JUST_BUILT: ${{ github.event.client_payload.ref }}
OCELOT_GITHUB_RUN_NUMBER: ${{ github.event.client_payload.GITHUB_RUN_NUMBER }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Decrypt .env
run: gpg --quiet --batch --yes --decrypt --passphrase="${{ env.SECRET }}" --output .env .env.enc
- name: Load .env
uses: aarcangeli/[email protected]
with:
quiet: true
- name: Set GITHUB_OCELOT_REF
run: |
if [ -z ${GITHUB_OCELOT_REF} ]; then
echo "GITHUB_OCELOT_REF=${GITHUB_OCELOT_REF_JUST_BUILT}" >> $GITHUB_ENV
fi
shell: bash
- name: Checkout Ocelot code
uses: actions/checkout@v3
with:
repository: 'Ocelot-Social-Community/Ocelot-Social'
ref: ${{ env.GITHUB_OCELOT_REF }}
path: 'ocelot/'
fetch-depth: 0
- name: Set OCELOT_GITHUB_RUN_NUMBER
run: |
if [ -z ${OCELOT_GITHUB_RUN_NUMBER} ]; then
echo "OCELOT_GITHUB_RUN_NUMBER=${GITHUB_OCELOT_REF}" >> $GITHUB_ENV
fi
if [ -z ${OCELOT_GITHUB_RUN_NUMBER} ]; then
echo "OCELOT_GITHUB_RUN_NUMBER=master" >> $GITHUB_ENV
fi
shell: bash
- name: Setup env
run: |
echo "OCELOT_VERSION=$(node -p -e "require('./ocelot/package.json').version")" >> $GITHUB_ENV
echo "BRANDED_VERSION=${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV
- run: echo "BUILD_VERSION=${BRANDED_VERSION}-ocelot.social${OCELOT_VERSION}-${OCELOT_GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
- name: package-version-to-git-tag + build number
uses: pkgdeps/git-tag-action@v2
with:
github_token: ${{ github.token }} #${{ secrets.GITHUB_TOKEN }}
github_repo: ${{ github.repository }}
version: ${{ env.BUILD_VERSION }}
git_commit_sha: ${{ github.sha }}
git_tag_prefix: "b"
#- name: Generate changelog
# run: |
# yarn install
# yarn auto-changelog --latest-version ${{ env.VERSION }} --unreleased-only
- name: package-version-to-git-release
continue-on-error: true # Will fail if tag exists
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ github.token }} #${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.BUILD_VERSION }}
release_name: ${{ env.BUILD_VERSION }}
#body_path: ./CHANGELOG.md
draft: false
prerelease: false
# TODO correct version
build_trigger:
name: Trigger successful brand build
runs-on: ubuntu-latest
needs: [github_tag]
env:
SECRET: ${{ secrets.SECRET }}
GITHUB_OCELOT_REF_JUST_BUILT: ${{ github.event.client_payload.ref }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Decrypt .env
run: gpg --quiet --batch --yes --decrypt --passphrase="${{ env.SECRET }}" --output .env .env.enc
- name: Load .env
uses: aarcangeli/[email protected]
with:
quiet: true
- name: Set GITHUB_OCELOT_REF
run: |
if [ -z ${GITHUB_OCELOT_REF} ]; then
echo "GITHUB_OCELOT_REF=${GITHUB_OCELOT_REF_JUST_BUILT}" >> $GITHUB_ENV
fi
shell: bash
- name: Checkout Ocelot code
uses: actions/checkout@v3
with:
repository: 'Ocelot-Social-Community/Ocelot-Social'
ref: ${{ env.GITHUB_OCELOT_REF }}
path: 'ocelot/'
fetch-depth: 0
- name: Set OCELOT_GITHUB_RUN_NUMBER
run: |
if [ -z ${OCELOT_GITHUB_RUN_NUMBER} ]; then
echo "OCELOT_GITHUB_RUN_NUMBER=${GITHUB_OCELOT_REF}" >> $GITHUB_ENV
fi
if [ -z ${OCELOT_GITHUB_RUN_NUMBER} ]; then
echo "OCELOT_GITHUB_RUN_NUMBER=master" >> $GITHUB_ENV
fi
shell: bash
- name: Setup env
run: |
echo "OCELOT_VERSION=$(node -p -e "require('./ocelot/package.json').version")" >> $GITHUB_ENV
echo "BRANDED_VERSION=${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
echo "BUILD_COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV
- run: echo "BUILD_VERSION=${BRANDED_VERSION}-ocelot.social${OCELOT_VERSION}-${OCELOT_GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ github.token }}
event-type: trigger-ocelot-brand-build-success
repository: ${{ github.repository }}
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "ref_ocelot": "${{ github.event.client_payload.ref }}", "sha_ocelot": "${{ github.event.client_payload.sha }}", "OCELOT_VERSION": "${{ env.OCELOT_VERSION }}", "BRANDED_VERSION": "${{ env.BRANDED_VERSION }}", "BUILD_DATE": "${{ env.BUILD_DATE }}", "BUILD_COMMIT": "${{ env.BUILD_COMMIT }}", "BUILD_VERSION": "${{ env.BUILD_VERSION }}"}'