-
Notifications
You must be signed in to change notification settings - Fork 0
228 lines (213 loc) · 8.51 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
---
name: Deploy
# yamllint disable-line rule:truthy
on:
release:
types:
- published
workflow_run:
workflows: ["CI"]
branches: [main]
types:
- completed
jobs:
information:
name: Gather add-on information
runs-on: ubuntu-latest
outputs:
build_date: ${{ steps.information.outputs.build_date }}
description: ${{ steps.information.outputs.description }}
environment: ${{ steps.information.outputs.environment }}
name: ${{ steps.information.outputs.name }}
vendor: ${{ steps.information.outputs.vendor }}
version: ${{ steps.information.outputs.version }}
sha_short: ${{ steps.information.outputs.sha_short }}
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v2
- name: ℹ️ Gather version and environment
id: information
shell: bash
# yamllint disable rule:line-length
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}"
echo ::set-output name=name::$(jq -r .name config.json)
echo ::set-output name=description::$(jq -r .description config.json)
echo ::set-output name=vendor::$(jq -r .vendor config.json)
echo ::set-output name=build_date::$(date -u +%Y-%m-%dT%H:%M:%SZ)
echo ::set-output name=sha_short::$(git rev-parse --short HEAD)
# yamllint enable rule:line-length
- name: 🛡 Protect Production
if: steps.information.outputs.environment == 'production'
# yamllint disable rule:line-length
run: |
echo "::error title=Invalid Branch::The production branch is invalid and must not be used."
echo "Do not use the `production` branch."
echo "To push into production, make a PR against main."
echo "Then use releases and publish the draft"
echo "that has been generated for you."
echo "This code has NOT been deployed."
echo "*****"
echo "Nothing futher will be done until"
echo "the production branch is deleted."
echo "*****"
exit 1
# yamllint enable rule:line-length
build:
name: 👷 Build ${{ matrix.os }} ${{ matrix.tag }} ${{ matrix.architecture }}
needs:
- information
runs-on: ${{ matrix.architecture }}
strategy:
fail-fast: true
matrix:
os: ["debian", "raspbian/stretch"]
tag: ["bullseye-slim", "latest"]
dockerfile: ["general", "raspberry"]
architecture: ["ubuntu-latest", "ARM"]
platform:
[
"linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x",
"linux/arm/v6,linux/arm/v7,linux/arm64/v8",
]
exclude:
- os: "raspbian/stretch"
tag: "bullseye-slim"
- os: "debian"
tag: "latest"
- os: "raspbian/stretch"
# yamllint disable-line rule:line-length
platform: "linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x"
- os: "debian"
platform: "linux/arm/v6,linux/arm/v7,linux/arm64/v8"
- os: "raspbian/stretch"
dockerfile: "general"
- os: "debian"
dockerfile: "raspberry"
- os: "raspbian/stretch"
architecture: "ubuntu-latest"
- os: "debian"
architecture: "ARM"
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
persist-credentials: false
- name: 📝 Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/aperim/vlc-player-${{ matrix.dockerfile }}
aperimau/vlc-player-${{ matrix.dockerfile }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: 🏗 Set up build cache
id: cache
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
# yamllint disable-line rule:line-length
key: ${{ runner.os }}-buildx-${{ matrix.os }}-${{ matrix.tag }}-${{ matrix.architecture }}-${{ github.sha }}
# yamllint disable rule:line-length
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.os }}-${{ matrix.tag }}-${{ matrix.architecture }}-${{ github.sha }}
${{ runner.os }}-buildx-${{ matrix.os }}-${{ matrix.tag }}-${{ matrix.architecture }}
${{ runner.os }}-buildx-${{ matrix.os }}-${{ matrix.tag }}
${{ runner.os }}-buildx-${{ matrix.os }}
${{ runner.os }}-buildx
# yamllint enable rule:line-length
- name: 🏗 Set up QEMU
uses: docker/setup-qemu-action@v1
- name: 🏗 Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
install: true
- name: 🏗 Set up CodeNotary
run: bash <(curl https://getvcn.codenotary.com -L)
- name: 🏗 Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.APERIM_GITHUB_CI_PAT }}
- name: 🏗 Login to Dockeer Container Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: 🚀 Build
uses: docker/build-push-action@v2
with:
push: true
builder: ${{ steps.buildx.outputs.name }}
context: ./container
file: "./container/Dockerfile.${{ matrix.dockerfile }}"
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
platforms: ${{ matrix.platform }}
build-args: |
BUILD_DATE=${{ needs.information.outputs.build_date }}
BUILD_DESCRIPTION=${{ needs.information.outputs.description }}
BUILD_NAME=${{ needs.information.outputs.name }}
BUILD_REF=${{ github.sha }}
BUILD_REPOSITORY=${{ github.repository }}
BUILD_VERSION=${{ needs.information.outputs.version }}
BUILD_VENDOR=${{ needs.information.outputs.vendor }}
ENVIRONMENT=${{ needs.information.outputs.description }}
OS_CONTAINER=${{ matrix.os }}
OS_VARIENT=${{ matrix.tag }}
# This ugly bit is necessary, or our cache will grow forever...
# Well until we hit GitHub's limit of 5GB :)
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: 🚚 Swap build cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: 🔏 Notarize
# yamllint disable rule:line-length
run: |
if vcn authenticate \
--output json \
"docker://ghcr.io/aperim/vlc-player-${{ matrix.dockerfile }}:sha-${{ needs.information.outputs.sha_short }}" \
| jq \
--exit-status \
'.verification.status != 0';
then
vcn login
vcn notarize \
--public \
"docker://ghcr.io/aperim/vlc-player-${{ matrix.dockerfile }}:sha-${{ needs.information.outputs.sha_short }}"
fi
# yamllint enable rule:line-length
env:
VCN_USER: ${{ secrets.VCN_USER }}
VCN_PASSWORD: ${{ secrets.VCN_PASSWORD }}
VCN_NOTARIZATION_PASSWORD: ${{ secrets.VCN_NOTARIZATION_PASSWORD }}
VCN_OTP_EMPTY: true