-
-
Notifications
You must be signed in to change notification settings - Fork 65
254 lines (246 loc) Β· 9.74 KB
/
deploy.yaml
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
---
name: Deploy
# yamllint disable-line rule:truthy
on:
release:
types:
- published
workflow_run:
workflows: ["CI"]
branches: [main]
types:
- completed
jobs:
information:
if: |
github.event_name == 'release'
|| (
github.event_name == 'workflow_run'
&& github.event.workflow_run.conclusion == 'success'
)
name: βΉοΈ Gather add-on information
runs-on: ubuntu-latest
outputs:
architectures: ${{ steps.information.outputs.architectures }}
build: ${{ steps.information.outputs.build }}
description: ${{ steps.information.outputs.description }}
environment: ${{ steps.release.outputs.environment }}
name: ${{ steps.information.outputs.name }}
slug: ${{ steps.information.outputs.slug }}
target: ${{ steps.information.outputs.target }}
version: ${{ steps.release.outputs.version }}
steps:
- name: β€΅οΈ Check out code from GitHub
uses: actions/[email protected]
- name: π Run add-on information action
id: information
uses: frenck/[email protected]
- name: βΉοΈ Gather version and environment
id: release
run: |
sha="${{ github.sha }}"
environment="edge"
version="${sha:0:7}"
if [[ "${{ github.event_name }}" = "release" ]]; then
version="${{ github.event.release.tag_name }}"
version="${version,,}"
version="${version#v}"
environment="stable"
if [[ "${{ github.event.release.prerelease }}" = "true" ]]; then
environment="beta"
fi
fi
echo "::set-output name=environment::${environment}"
echo "::set-output name=version::${version}"
deploy:
name: π· Build & Deploy ${{ matrix.architecture }}
needs: information
runs-on: ubuntu-latest
strategy:
matrix:
architecture: ${{ fromJson(needs.information.outputs.architectures) }}
steps:
- name: π Wait for other runs to complete
uses: softprops/turnstyle@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: β€΅οΈ Check out code from GitHub
uses: actions/[email protected]
- name: π Set up build cache
id: cache
uses: actions/[email protected]
with:
path: /tmp/.docker-cache
key:
docker-${{ github.ref }}-${{ matrix.architecture }}-${{ github.sha
}}
restore-keys: |
docker-${{ github.ref }}-${{ matrix.architecture }}
- name: π Set up QEMU
uses: docker/[email protected]
- name: π Set up Docker Buildx
uses: docker/[email protected]
- name: π Set up CodeNotary
run: bash <(curl https://getvcn.codenotary.com -L)
- name: βΉοΈ Compose build flags
id: flags
run: |
echo "::set-output name=date::$(date +"%Y-%m-%dT%H:%M:%SZ")"
from=$(jq --raw-output ".build_from.${{ matrix.architecture }}" "${{ needs.information.outputs.build }}")
echo "::set-output name=from::${from}"
if [[ "${{ matrix.architecture}}" = "amd64" ]]; then
echo "::set-output name=platform::linux/amd64"
elif [[ "${{ matrix.architecture }}" = "i386" ]]; then
echo "::set-output name=platform::linux/386"
elif [[ "${{ matrix.architecture }}" = "armhf" ]]; then
echo "::set-output name=platform::linux/arm/v6"
elif [[ "${{ matrix.architecture }}" = "armv7" ]]; then
echo "::set-output name=platform::linux/arm/v7"
elif [[ "${{ matrix.architecture }}" = "aarch64" ]]; then
echo "::set-output name=platform::linux/arm64/v8"
else
echo "::error ::Could not determine platform for architecture ${{ matrix.architecture }}"
exit 1
fi
- name: π Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: β€΅οΈ Download base image
run: docker pull "${{ steps.flags.outputs.from }}"
- name: β
Verify authenticity of base image
run: |
vcn authenticate \
"docker://${{ steps.flags.outputs.from }}"
vcn authenticate \
--output json \
--signerID 0x03e406879fd89e52f38f4aab0061266d1183980a \
"docker://${{ steps.flags.outputs.from }}" \
| jq \
--exit-status \
'.verification.status == 0'
- name: π Build
uses: docker/[email protected]
with:
load: true
# yamllint disable rule:line-length
tags: |
ghcr.io/hassio-addons/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.environment }}
ghcr.io/hassio-addons/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.version }}
# yamllint enable rule:line-length
context: ${{ needs.information.outputs.target }}
file: ${{ needs.information.outputs.target }}/Dockerfile
cache-from: |
type=local,src=/tmp/.docker-cache
ghcr.io/hassio-addons/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:edge
cache-to: type=local,mode=max,dest=/tmp/.docker-cache
platforms: ${{ steps.flags.outputs.platform }}
build-args: |
BUILD_ARCH=${{ matrix.architecture }}
BUILD_DATE=${{ steps.flags.outputs.date }}
BUILD_DESCRIPTION=${{ needs.information.outputs.description }}
BUILD_FROM=${{ steps.flags.outputs.from }}
BUILD_NAME=${{ needs.information.outputs.name }}
BUILD_REF=${{ github.sha }}
BUILD_REPOSITORY=${{ github.repository }}
BUILD_VERSION=${{ needs.information.outputs.version }}
- name: π Notarize
# yamllint disable rule:line-length
run: |
if vcn authenticate \
--output json \
"docker://ghcr.io/hassio-addons/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.version }}" \
| jq \
--exit-status \
'.verification.status != 0';
then
vcn login
vcn notarize \
--public \
"docker://ghcr.io/hassio-addons/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.version }}"
fi
env:
VCN_USER: ${{ secrets.VCN_USER }}
VCN_PASSWORD: ${{ secrets.VCN_PASSWORD }}
VCN_NOTARIZATION_PASSWORD: ${{ secrets.VCN_NOTARIZATION_PASSWORD }}
VCN_OTP_EMPTY: true
- name: π Push
# yamllint disable rule:line-length
run: |
docker push \
"ghcr.io/hassio-addons/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.environment }}"
docker push \
"ghcr.io/hassio-addons/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:${{ needs.information.outputs.version }}"
publish-edge:
name: π’ Publish to edge repository
if: needs.information.outputs.environment == 'edge'
needs:
- information
- deploy
environment:
name: ${{ needs.information.outputs.environment }}
runs-on: ubuntu-latest
steps:
- name: π Dispatch repository updater update signal
uses: peter-evans/[email protected]
with:
token: ${{ secrets.DISPATCH_TOKEN }}
repository: hassio-addons/repository-edge
event-type: update
client-payload: >
{
"addon": "${{ needs.information.outputs.slug }}",
"name": "${{ needs.information.outputs.name }}",
"repository": "${{ github.repository }}",
"version": "${{ needs.information.outputs.version }}"
}
publish-beta:
name: π’ Publish to beta repository
if: |
needs.information.outputs.environment == 'beta' ||
needs.information.outputs.environment == 'stable'
needs:
- information
- deploy
environment:
name: ${{ needs.information.outputs.environment }}
runs-on: ubuntu-latest
steps:
- name: π Dispatch repository updater update signal
uses: peter-evans/[email protected]
with:
token: ${{ secrets.DISPATCH_TOKEN }}
repository: hassio-addons/repository-beta
event-type: update
client-payload: >
{
"addon": "${{ needs.information.outputs.slug }}",
"name": "${{ needs.information.outputs.name }}",
"repository": "${{ github.repository }}",
"version": "${{ github.event.release.tag_name }}"
}
publish-stable:
name: π’ Publish to stable repository
if: needs.information.outputs.environment == 'stable'
needs:
- information
- deploy
environment:
name: ${{ needs.information.outputs.environment }}
runs-on: ubuntu-latest
steps:
- name: π Dispatch repository updater update signal
uses: peter-evans/[email protected]
with:
token: ${{ secrets.DISPATCH_TOKEN }}
repository: hassio-addons/repository
event-type: update
client-payload: >
{
"addon": "${{ needs.information.outputs.slug }}",
"name": "${{ needs.information.outputs.name }}",
"repository": "${{ github.repository }}",
"version": "${{ github.event.release.tag_name }}"
}