Skip to content

Build k3s

Build k3s #305

Workflow file for this run

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 }}