-
Notifications
You must be signed in to change notification settings - Fork 9
216 lines (206 loc) · 7.39 KB
/
ci.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
---
name: CI
# yamllint disable-line rule:truthy
on:
push:
pull_request:
types:
- opened
- reopened
- synchronize
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
information:
name: Gather add-on information
runs-on: ubuntu-latest
outputs:
architectures: ${{ steps.information.outputs.architectures }}
base_image_signer: ${{ steps.information.outputs.codenotary_base_image }}
build: ${{ steps.information.outputs.build }}
description: ${{ steps.information.outputs.description }}
name: ${{ steps.information.outputs.name }}
slug: ${{ steps.override.outputs.slug }}
target: ${{ steps.information.outputs.target }}
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4
- name: 🚀 Run add-on information action
id: information
uses: frenck/[email protected]
- name: 🚀 Process possible slug override
id: override
run: |
slug="${{ steps.information.outputs.slug }}"
if [[ ! -z "${{ inputs.slug }}" ]]; then
slug="${{ inputs.slug }}"
fi
echo "slug=$slug" >> "$GITHUB_OUTPUT"
lint-addon:
name: Lint Add-on
needs:
- information
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4
- name: 🚀 Run Add-on Lint
uses: frenck/[email protected]
with:
community: true
path: "./${{ needs.information.outputs.target }}"
# lint-hadolint:
# name: Hadolint
# needs:
# - information
# runs-on: ubuntu-latest
# steps:
# - name: ⤵️ Check out code from GitHub
# uses: actions/checkout@v4
# - name: 🚀 Run Hadolint
# uses: brpaz/[email protected]
# with:
# dockerfile: "./${{ needs.information.outputs.target }}/Dockerfile"
lint-json:
name: JSON Lint
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4
- name: 🚀 Run JQ
run: |
shopt -s globstar
cat **/*.json | jq '.'
# lint-markdown:
# name: MarkdownLint
# runs-on: ubuntu-latest
# steps:
# - name: ⤵️ Check out code from GitHub
# uses: actions/checkout@v4
# - name: 🚀 Run mdl
# uses: actionshub/[email protected]
# lint-shellcheck:
# name: Shellcheck
# runs-on: ubuntu-latest
# steps:
# - name: ⤵️ Check out code from GitHub
# uses: actions/checkout@v4
# - name: 🚀 Run Shellcheck
# uses: ludeeus/[email protected]
# env:
# SHELLCHECK_OPTS: -s bash
# lint-yamllint:
# name: YAMLLint
# runs-on: ubuntu-latest
# steps:
# - name: ⤵️ Check out code from GitHub
# uses: actions/checkout@v4
# - name: 🚀 Run YAMLLint
# uses: frenck/[email protected]
# lint-prettier:
# name: Prettier
# runs-on: ubuntu-latest
# steps:
# - name: ⤵️ Check out code from GitHub
# uses: actions/checkout@v4
# - name: 🚀 Run Prettier
# uses: creyD/[email protected]
# with:
# prettier_options: --write **/*.{json,js,md,yaml}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
name: Build ${{ matrix.architecture }}
needs:
- information
- lint-addon
#- lint-hadolint
- lint-json
#- lint-prettier
#- lint-shellcheck
#- lint-yamllint
runs-on: ubuntu-latest
strategy:
matrix:
architecture: ${{ fromJson(needs.information.outputs.architectures) }}
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v4
- name: 🚚 Make build cache folder
run: |
mkdir -p /tmp/.docker-cache
- name: 🏗 Set up build cache
id: cache
uses: actions/[email protected]
with:
path: /tmp/.docker-cache
key: docker-${{ matrix.architecture }}-${{ github.sha }}
restore-keys: |
docker-${{ matrix.architecture }}
- name: 🏗 Set up QEMU
uses: docker/[email protected]
- name: 🏗 Set up Docker Buildx
uses: docker/[email protected]
#- name: 🏗 Set up Codenotary Community Attestation Service (CAS)
# uses: frenck/[email protected]
# with:
# version: v1.0.3
- name: ℹ️ Compose build flags
id: flags
run: |
echo "date=$(date +"%Y-%m-%dT%H:%M:%SZ")" >> "$GITHUB_OUTPUT"
from=$(yq --no-colors eval ".build_from.${{ matrix.architecture }}" "${{ needs.information.outputs.build }}")
echo "from=${from}" >> "$GITHUB_OUTPUT"
if [[ "${{ matrix.architecture}}" = "amd64" ]]; then
echo "platform=linux/amd64" >> "$GITHUB_OUTPUT"
elif [[ "${{ matrix.architecture }}" = "i386" ]]; then
echo "platform=linux/386" >> "$GITHUB_OUTPUT"
elif [[ "${{ matrix.architecture }}" = "armhf" ]]; then
echo "platform=linux/arm/v6" >> "$GITHUB_OUTPUT"
elif [[ "${{ matrix.architecture }}" = "armv7" ]]; then
echo "platform=linux/arm/v7" >> "$GITHUB_OUTPUT"
elif [[ "${{ matrix.architecture }}" = "aarch64" ]]; then
echo "platform=linux/arm64/v8" >> "$GITHUB_OUTPUT"
else
echo "::error ::Could not determine platform for architecture ${{ matrix.architecture }}"
exit 1
fi
- name: ⤵️ Download base image
if: steps.flags.outputs.from != 'null'
run: docker pull "${{ steps.flags.outputs.from }}"
#- name: ✅ Verify authenticity of base image
# if: steps.flags.outputs.from != 'null' && needs.information.outputs.base_image_signer != 'null'
# run: |
# cas authenticate \
# --signerID "${{ needs.information.outputs.base_image_signer }}" \
# "docker://${{ steps.flags.outputs.from }}"
- name: 🚀 Build
uses: docker/[email protected]
with:
push: false
context: ${{ needs.information.outputs.target }}
file: ${{ needs.information.outputs.target }}/Dockerfile
cache-from: |
type=local,src=/tmp/.docker-cache
ghcr.io/${{ github.repository_owner }}/${{ needs.information.outputs.slug }}/${{ matrix.architecture }}:edge
cache-to: type=local,mode=max,dest=/tmp/.docker-cache-new
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=edge
# 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/.docker-cache
mv /tmp/.docker-cache-new /tmp/.docker-cache