Skip to main content

GitHub Actions

Quick Start

Use a GitHub Action to build and push a new Acorn into a Packages repository each time a new version is tagged:

# Save into your repo as .github/workflows/on-tag.yaml
name: On Tag
on:
push:
tags:
- "v*"
jobs:
publish:
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- uses: acorn-io/actions-[email protected]
- uses: acorn-io/actions-[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set Tag
run: |
echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build and Push
run: |
acorn build -t ghcr.io/${{ github.repository }}:$TAG .
acorn push ghcr.io/${{ github.repository }}:$TAG

The action is automatically provided with a GITHUB_TOKEN that already has permission to push to the registry for its own repo, so no special secrets configuration is needed.

You can choose any other Linux or macOS runner for the runs-on, see GitHub Docs for available choices or specify your own self-hosted runner.

Setup Action

The setup action creates a k3s cluster, installs acorn, and hooks everything up so you can use the acorn CLI just like you would from your workstation.

Usage

name: My Workflow
on:
push: {}
jobs:
publish:
steps:
- uses: actions/[email protected]
- uses: acorn-io/actions-[email protected]
- run: |
# Do something with the CLI
acorn --version

Options

KeyDefaultDescription
acorn-versionlatestVersion of Acorn to install
k3s-versionlatestVersion of K3s to install

See actions-setup for additional advanced options. For example it is possible to point acorn at an existing k8s cluster instead of spinning up a new one.

Login Action

The login action logs into a registry so that later steps can push an acorn to it.

Usage

name: My Workflow
on:
push:
tags:
- "v*"
jobs:
publish:
steps:
- uses: actions/[email protected]
- uses: acorn-io/actions-[email protected]
- uses: acorn-io/actions-[email protected]
with:
registry: docker.io
username: yourDockerHubUsername
password: ${{ secrets.DOCKERHUB_PASSWORD }}

Options

KeyDefaultDescription
registryRequiredRegistry address to login to (e.g. ghcr.io or docker.io)
usernameRequiredRegistry username
passwordRequiredRegistry password