Switch to MattKobayashi/tailscale-runner-action
#75
Workflow file for this run
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 and test container images | |
on: | |
pull_request: | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
create-runners: | |
name: Create self-hosted Actions runner | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
max-parallel: 4 | |
matrix: | |
runner-name: [ | |
actions-runner, | |
avahi, | |
certbot-cloudflare, | |
fullbogons, | |
growatt-ev, | |
iperf2, | |
iperf3, | |
irrd, | |
mdns-reflector, | |
rng-tools, | |
speedtest, | |
stun, | |
telegraf, | |
verlihub, | |
vyos-release-alert, | |
xteve, | |
yancobat | |
] | |
steps: | |
- name: Create self-hosted Actions runner | |
uses: MattKobayashi/[email protected] | |
with: | |
gh-app-id: ${{ secrets.GH_APP_ID }} | |
gh-app-login: MattKobayashi | |
gh-app-private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | |
runner-network: mattflix | |
ssh-host: 100.102.37.118 | |
ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }} | |
ssh-user: matthew | |
ts-oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }} | |
ts-oauth-secret: ${{ secrets.TS_OAUTH_SECRET }} | |
ts-tag: ci | |
build-setup: | |
name: Set up build environment | |
runs-on: ubuntu-latest | |
outputs: | |
repo-owner: ${{ steps.repo-lowercase.outputs.REPO_OWNER }} | |
steps: | |
- name: Convert repository owner name to lowercase | |
id: repo-lowercase | |
run: | | |
echo "REPO_OWNER=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_OUTPUT | |
build-test: | |
name: Build and test image | |
runs-on: self-hosted | |
needs: [create-runners, build-setup] | |
strategy: | |
fail-fast: false | |
max-parallel: 2 | |
matrix: | |
container: [ | |
actions-runner, | |
avahi, | |
certbot-cloudflare, | |
fullbogons, | |
growatt-ev, | |
iperf2, | |
iperf3, | |
mdns-reflector, | |
rng-tools, | |
speedtest, | |
stun, | |
telegraf, | |
verlihub, | |
vyos-release-alert, | |
xteve, | |
yancobat | |
] | |
steps: | |
# Checkout repository | |
# https://github.com/actions/checkout | |
- name: Checkout repository | |
uses: actions/[email protected] | |
# Set up QEMU | |
# https://github.com/docker/setup-qemu-action | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
# Set up Docker Buildx | |
# https://github.com/docker/setup-buildx-action | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
with: | |
buildkitd-config-inline: | | |
[registry."docker.io"] | |
mirrors = ["registry-mirror:5000"] | |
[registry."registry-mirror:5000"] | |
http = true | |
driver-opts: | | |
network=mattflix | |
# Build and export image to Docker daemon | |
# https://github.com/docker/build-push-action | |
- name: Build and export to Docker | |
uses: docker/[email protected] | |
with: | |
context: ${{ matrix.container }} | |
load: true | |
tags: "${{ needs.build-setup.outputs.repo-owner }}/${{ matrix.container }}:test" | |
# Test the built image | |
- name: Test image | |
run: | | |
set -x | |
timeout --kill-after=30s --preserve-status 30s \ | |
docker container run --attach stdout --attach stderr --init --rm ${{ needs.build-setup.outputs.repo-owner }}/${{ matrix.container }}:test | |
# Remove the test image | |
- name: Remove test image | |
if: ${{ !cancelled() }} | |
run: | | |
set -x | |
docker image rm ${{ needs.build-setup.outputs.repo-owner }}/${{ matrix.container }}:test | |
build-test-noinit: | |
name: Build and test image without `--init` | |
runs-on: self-hosted | |
needs: [create-runners, build-setup] | |
strategy: | |
fail-fast: false | |
max-parallel: 2 | |
matrix: | |
container: [ | |
irrd | |
] | |
steps: | |
# Checkout repository | |
# https://github.com/actions/checkout | |
- name: Checkout repository | |
uses: actions/[email protected] | |
# Set up QEMU | |
# https://github.com/docker/setup-qemu-action | |
- name: Set up QEMU | |
uses: docker/[email protected] | |
# Set up Docker Buildx | |
# https://github.com/docker/setup-buildx-action | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
with: | |
buildkitd-config-inline: | | |
[registry."docker.io"] | |
mirrors = ["registry-mirror:5000"] | |
[registry."registry-mirror:5000"] | |
http = true | |
driver-opts: | | |
network=mattflix | |
# Build and export image to Docker daemon | |
# https://github.com/docker/build-push-action | |
- name: Build and export to Docker | |
uses: docker/[email protected] | |
with: | |
context: ${{ matrix.container }} | |
load: true | |
tags: "${{ needs.build-setup.outputs.repo-owner }}/${{ matrix.container }}:test" | |
# Install uuid-runtime package | |
- name: Install `uuid-runtime` | |
run: | | |
set -x | |
apt-get --yes install uuid-runtime | |
# Test the built image | |
- name: Test image | |
run: | | |
set -x | |
CONTAINER_ID="$(uuidgen)" | |
docker container run --attach=stdout --attach=stderr --init --name=$CONTAINER_ID --rm ${{ needs.build-setup.outputs.repo-owner }}/${{ matrix.container }}:test & | |
sleep 60 | |
docker container stop $CONTAINER_ID | |
# Remove the test image | |
- name: Remove test image | |
if: ${{ !cancelled() }} | |
run: | | |
set -x | |
docker image rm --force ${{ needs.build-setup.outputs.repo-owner }}/${{ matrix.container }}:test |