The Unikraft GitHub Actions is designed to programmatically manage repositories that can be built as a Unikraft unikernel via GitHub Workflows:
Kraftfile
;View the Action on the GitHub Marketplace:
https://github.com/marketplace/actions/build-unikernel-images-with-unikraft
In the following example, a repository that has been initialized with a
top-level Kraftfile
that contains a
target for qemu/x86_64
will be built
every time a PR is opened, synchronized or re-opened:
name: example1on:pull_request:types: [opened, synchronize, reopened]jobs:build:steps:- uses: actions/checkout@v3- uses: unikraft/kraftkit@stablewith:workdir: .kraftfile: Kraftfilearch: x86_64plat: qemu
If your project has multiple targets,
you can use the workflow matrix
syntax
which enumerates matrices to build each target independently:
name: example2jobs:build:strategy:fail-fast: falsematrix:include:- plat: qemuarch: x86_64- plat: qemuarch: arm64steps:- uses: actions/checkout@v3- uses: unikraft/kraftkit@stablewith:workdir: .kraftfile: Kraftfileplat: ${{matrix.plat}}arch: ${{matrix.arch}}
Applications which are designed as run-to-completion, meaning that they execute
a single task non-continuously and exit, can be executed by the GitHub action
via QEMU's TCG (which emulates
hardware ISA). Simply enable the execute: true
attribute of the action. This
is useful for applications which perform a single task, or run a suite of tests:
name: example3on:pull_request:types: [opened, synchronize, reopened]jobs:build:steps:- uses: actions/checkout@v3- uses: unikraft/kraftkit@stablewith:workdir: .kraftfile: Kraftfilearch: x86_64plat: qemuexecute: true
See an example with Unikraft's official workflow which runs the internal test suite
uktest
.
Kraftfile
#For more complex scenarios where you may wish to do variable substitutions in
the workflow file, it is possible to embed the Kraftfile
directly in the
action, this is possible using the following syntax:
name: example4on:pull_request:types: [opened, synchronize, reopened]jobs:build:steps:- uses: actions/checkout@v3- uses: unikraft/kraftkit@stablewith:workdir: .kraftfile: |specification: v0.5unikraft: stablelibraries:musl: stabletargets:- plat: qemuarch: x86_64arch: x86_64plat: qemu
The GitHub action, for now, only supports packaging the resulting unikernel
image in OCI Image
format. This
allows you to distribute the image using conventional OCI Image Registries, such
as the one provided by GitHub
(GHCR).
This image format is also recognized by kraft
. To publish your image in
a registry, you must first login to the registry and then specify the canonical
name via output: oci://...
and indicate you wish to push
the image:
name: example5on:pull_request:types: [opened, synchronize, reopened]jobs:build:steps:- uses: actions/checkout@v3- name: Login to OCI registryuses: docker/login-action@v2with:registry: ghcr.iousername: ${{ secrets.REG_USERNAME }}password: ${{ secrets.REG_TOKEN }}- uses: unikraft/kraftkit@stablewith:workdir: .kraftfile: Kraftfilearch: x86_64plat: qemuoutput: oci://ghcr.io/username/repo:latestpush: true
Feel free to ask questions, report issues, and meet new people.