Build k3s #187
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/github-action-get-latest-release@v0.7.0 | |
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/tag-exists-action@v1.5.0 | |
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/github-tagger@v0.0.1 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
tag: ${{ steps.k3s-version.outputs.release }} |