-
Notifications
You must be signed in to change notification settings - Fork 4
78 lines (66 loc) · 2.31 KB
/
build.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
name: Build k3s
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
version:
description: 'The version of K3S to build an image for, e.g. v1.29.0+k3s1'
required: false
type: string
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: 'write'
id-token: 'write'
steps:
- id: latest-k3s
uses: pozetroninc/[email protected]
with:
owner: k3s-io
repo: k3s
excludes: prerelease, draft
- id: k3s-version
run: |
echo "release=${{ (github.event.inputs.version != '') && github.event.inputs.version || steps.latest-k3s.outputs.release }}" >> $GITHUB_OUTPUT
- id: tag-exists
uses: mukunku/[email protected]
with:
tag: ${{ steps.k3s-version.outputs.release }}
- uses: actions/checkout@v2
if: ${{ steps.tag-exists.outputs.exists == 'false' }}
- name: Authenticate
if: ${{ steps.tag-exists.outputs.exists == 'false' }}
uses: 'google-github-actions/auth@v2'
with:
project_id: instruqt
credentials_json: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT }}
- name: Setup `packer`
if: ${{ steps.tag-exists.outputs.exists == 'false' }}
uses: hashicorp/setup-packer@main
id: setup
- name: Init
if: ${{ steps.tag-exists.outputs.exists == 'false' }}
id: init
run: "packer init k3s.pkr.hcl"
- name: Validate
if: ${{ steps.tag-exists.outputs.exists == 'false' }}
id: validate
run: "packer validate \
-var 'project_id=${{vars.PROJECT_ID}}' \
-var 'k3s_version=${{ steps.k3s-version.outputs.release }}' \
k3s.pkr.hcl"
- name: Build
if: ${{ steps.tag-exists.outputs.exists == 'false' }}
run: |
packer build -on-error=abort -color=false \
-var 'project_id=${{vars.PROJECT_ID}}' \
-var 'k3s_version=${{ steps.k3s-version.outputs.release }}' \
k3s.pkr.hcl
- name: Tag
if: ${{ steps.tag-exists.outputs.exists == 'false' }}
uses: tvdias/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.k3s-version.outputs.release }}