-
-
Notifications
You must be signed in to change notification settings - Fork 20
258 lines (222 loc) · 8.18 KB
/
build_addon.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
name: Build addon
on:
push:
branches:
- "*"
tags:
- "*"
pull_request:
env:
TARGET: nextcloud_backup
IMAGE: "hassio-nextcloud-backup"
REPOSITORY: ghcr.io/sebclem
IMAGE_SOURCE: https://github.com/Sebclem/hassio-nextcloud-backup
BASE_ISSUER: https://token.actions.githubusercontent.com
BASE_IDENTITY: https://github.com/home-assistant/docker-base/.*
permissions: write-all
jobs:
build-front:
name: Build Front
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Enable corepack
run: corepack enable
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
cache-dependency-path: nextcloud_backup/frontend/pnpm-lock.yaml
- name: Install dependencies
run: pnpm i
working-directory: nextcloud_backup/frontend
- name: Build
run: pnpm build
working-directory: nextcloud_backup/frontend
- name: Upload production-ready build files
uses: actions/upload-artifact@v4
with:
name: frontend
path: nextcloud_backup/frontend/dist/
build-back:
name: Build back
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Enable corepack
run: corepack enable
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
cache-dependency-path: nextcloud_backup/backend/pnpm-lock.yaml
- name: Install dependencies
run: pnpm i
working-directory: nextcloud_backup/backend
- name: Lint
run: pnpm lint
working-directory: nextcloud_backup/backend
- name: Build
run: pnpm build
working-directory: nextcloud_backup/backend
- name: Upload production-ready build files
uses: actions/upload-artifact@v4
with:
name: backend
path: nextcloud_backup/backend/dist/
build-dockers:
runs-on: ubuntu-latest
needs:
- build-back
- build-front
strategy:
fail-fast: false
matrix:
arch: [aarch64, amd64, armv7]
include:
- arch: aarch64
arch_value: linux/arm64/v8
- arch: amd64
arch_value: linux/amd64
- arch: armv7
arch_value: linux/arm/v7
steps:
- uses: actions/checkout@v4
- name: Install Cosign
uses: sigstore/[email protected]
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Get build parameters
id: build_param
run: |
echo "name=$(yq .name nextcloud_backup/config.yml)" >> $GITHUB_OUTPUT
echo "description=$(yq .description nextcloud_backup/config.yml)" >> $GITHUB_OUTPUT
echo "url=$(yq .url nextcloud_backup/config.yml)" >> $GITHUB_OUTPUT
echo "build_from=ghcr.io/home-assistant/${{ matrix.arch }}-base:$(cat nextcloud_backup/.base_version)" >> $GITHUB_OUTPUT
- name: Check base image signature
run: cosign verify --certificate-oidc-issuer-regexp "${{ env.BASE_ISSUER }}" --certificate-identity-regexp "${{ env.BASE_IDENTITY }}" "${{ steps.build_param.outputs['build_from'] }}"
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REPOSITORY }}/${{ env.IMAGE }}/${{ matrix.arch }}
tags: |
type=ref,event=branch
type=ref,event=branch,suffix=.${{ github.run_number }}
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
labels: |
io.hass.name=${{ steps.build_param.outputs['name'] }}
io.hass.description=${{ steps.build_param.outputs['description'] }}
io.hass.url=${{ steps.build_param.outputs['url'] }}
io.hass.arch=${{ matrix.arch }}
io.hass.type=addon
- name: Change version in config file
uses: fjogeleit/[email protected]
with:
valueFile: "nextcloud_backup/config.yml"
propertyPath: "version"
value: ${{ steps.meta.outputs.version }}.${{ github.run_number}}
commitChange: false
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push ${{matrix.arch}}
uses: docker/build-push-action@v6
id: build-and-push
with:
push: ${{ github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.event_name == 'release') }}
tags: ${{ steps.meta.outputs.tags }}
labels: |
${{ steps.meta.outputs.labels }}
io.hass.version=${{steps.meta.outputs.version}}
build-args: |
BUILD_FROM=${{ steps.build_param.outputs['build_from'] }}
file: ./${{ env.TARGET }}/Dockerfile
cache-from: type=registry,ref=${{ env.REPOSITORY }}/${{ env.IMAGE }}/${{ matrix.arch }}:latest
cache-to: type=inline
context: ./${{ env.TARGET }}/
platforms: ${{ matrix.arch_value }}
- name: Sign the images with GitHub OIDC Token
if: ${{ github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.event_name == 'release') }}
env:
DIGEST: ${{ steps.build-and-push.outputs.digest }}
TAGS: ${{ steps.meta.outputs.tags }}
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes ${images}
update_branch_ha_repository:
name: Update HA addon repository
runs-on: ubuntu-latest
needs:
- build-dockers
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
path: "addon"
- name: Get branch names
id: branch-names
uses: tj-actions/branch-names@v8
- name: Checkout Hass repo
uses: actions/checkout@v4
with:
repository: Sebclem/sebclem-hassio-addon-repository
path: "repository"
token: ${{ secrets.PAT_PR }}
ref: ${{ steps.branch-names.outputs.current_branch }}
- name: Generate readme
uses: cuchi/[email protected]
with:
template: addon/nextcloud_backup/.README.md.j2
output_file: repository/nextcloud_backup/README.md
variables: version=${{ steps.branch-names.outputs.current_branch }}.${{ github.run_number}}
- name: Move other files
run: |
cp addon/nextcloud_backup/DOCS.md repository/nextcloud_backup/
cp addon/nextcloud_backup/icon.png repository/nextcloud_backup/
cp addon/nextcloud_backup/logo.png repository/nextcloud_backup/
cp addon/nextcloud_backup/config.yml repository/nextcloud_backup/
- name: Update config.yml
run: |
yq -i '.version = "${{ steps.branch-names.outputs.current_branch }}.${{ github.run_number}}"' repository/nextcloud_backup/config.yml
yq -i '.image = "ghcr.io/sebclem/hassio-nextcloud-backup/{arch}"' repository/nextcloud_backup/config.yml
- name: Commit and push
run: |
cd repository
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Update Nextcloud Backup to ${{ steps.branch-names.outputs.current_branch }}.${{ github.run_number }}"
git push
draft-release:
name: Draft release
runs-on: ubuntu-latest
needs:
- build-dockers
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Get changelog
run: npx auto-changelog --handlebars-setup .github/custom-handlebars.js
- name: Create release
uses: softprops/action-gh-release@v2
with:
body_path: CHANGELOG.md
draft: true