jirutka / setup-alpine

Easily use Alpine Linux on GitHub Actions, with support for QEMU user emulator
MIT License
105 stars 16 forks source link
actions alpine-linux chroot ci cross-compile github-actions musl-libc qemu

= GitHub Action: Setup Alpine Linux :proj-name: setup-alpine :gh-name: jirutka/{proj-name} :gh-branch: v1 :action-ref: {gh-name}@{gh-branch} :alpine-latest: v3.15 :apk-tools: https://gitlab.alpinelinux.org/alpine/apk-tools/[apk-tools]

A https://github.com/features/actions[GitHub Action] to easily set up and use a chroot-based footnote:[If you don’t know what https://en.wikipedia.org/wiki/Chroot[chroot] is, think of it as a very simple container. It’s one of the cornerstones of containers and the only one that is actually needed for this use case.] https://alpinelinux.org/[Alpine Linux] environment in your workflows and emulate any supported CPU architecture (using QEMU).

[source, yaml, subs="+attributes"]

runs-on: ubuntu-latest steps:

== Highlights

== Parameters

=== Inputs

apk-tools-url:: URL of the apk-tools static binary to use. It must end with #!sha256! followed by a SHA-256 hash of the file. This should normally be left at the default value. + Default: see link:action.yml[]

[[arch]] arch:: CPU architecture to emulate using https://www.qemu.org/docs/master/user/main.html[QEMU user space emulator]. Allowed values are: x86_64 (native), x86 (native), aarch64, armhf footnote:[armhf is armv6 with hard-float.], armv7, ppc64le, riscv64 footnote:[riscv64 is available only for branch edge for now.], and s390x. + Default: x86_64

branch:: Alpine branch (aka release) to install: vMAJOR.MINOR, latest-stable, or edge. + Example: {alpine-latest} + Default: latest-stable

extra-keys:: A list of paths of additional trusted keys (for installing packages from the extra-repositories) to copy into /etc/apk/keys/. The paths should be relative to the workspace directory (the default location of your repository when using the checkout action). + Example: .keys/pkgs@example.org-56d0d9fd.rsa.pub

extra-repositories:: A list of additional Alpine repositories to add into /etc/apk/repositories (Alpine’s official main and community repositories are always added). + Example: http://dl-cdn.alpinelinux.org/alpine/edge/testing

mirror-url:: URL of an Alpine Linux mirror to fetch packages from. + Default: http://dl-cdn.alpinelinux.org/alpine

packages:: A list of Alpine packages to install. + Example: build-base openssh-client + Default: no extra packages

shell-name:: Name of the script to run sh in the Alpine chroot that will be added to GITHUB_PATH. This name should be used in jobs.<job_id>.steps[*].shell (e.g. shell: alpine.sh {0}) to run the step’s script in the chroot. + Default: alpine.sh

volumes:: A list of directories on the host system to mount bind into the chroot. You can specify the source and destination path: <src-dir>:<dest-dir>. The <src-dir> is an absolute path of existing directory on the host system, <dest-dir> is an absolute path in the chroot (it will be created if doesn’t exist). You can omit the latter if they're the same. + Please note that /home/runner/work (where’s your workspace located) is always mounted, don’t specify it here. + Example: ${{ steps.alpine-aarch64.outputs.root-path }}:/mnt/alpine-aarch64

=== Outputs

root-path:: Path to the created Alpine root directory.

[[examples]] == Usage examples

=== Basic usage

[source, yaml, subs="+attributes"]

runs-on: ubuntu-latest steps:

=== Set up Alpine with specified packages

[source, yaml, subs="+attributes"]

=== Set up and use Alpine for a different CPU architecture

[source, yaml, subs="+attributes"]

runs-on: ubuntu-latest steps:

=== Set up Alpine with packages from the testing repository

[source, yaml, subs="+attributes"]

=== Set up and use multiple Alpine environments in a single job

[source, yaml, subs="+attributes"]

runs-on: ubuntu-latest steps:

[[cross-compile-rust]] === Cross-compile Rust application with system libraries

[source, yaml, subs="+attributes"]

runs-on: ubuntu-latest strategy: matrix: include:

== History

This action is an evolution of the https://github.com/alpinelinux/alpine-chroot-install[alpine-chroot-install] script I originally wrote for Travis CI in 2016. The implementation is principally the same, but tailored to GitHub Actions. It’s so simple and fast thanks to how awesome {apk-tools} is!

== License

This project is licensed under http://opensource.org/licenses/MIT/[MIT License]. For the full text of the license, see the link:LICENSE[LICENSE] file.