-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (84 loc) · 2.61 KB
/
build-test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
name: Build and test container image
on:
pull_request:
branches:
- main
workflow_dispatch:
env:
REPO_NAME: mattkobayashi
IMAGE_NAME: fuelhook
jobs:
create-runner:
name: Create self-hosted Actions runner
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
runner-name: [
fuelhook
]
max-parallel: 1
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-user: matthew
ts-oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
ts-oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
ts-tag: ci
build-test:
name: Build and test container image
runs-on: self-hosted
needs: [create-runner]
permissions:
contents: read
steps:
# Add support for more platforms with QEMU (optional)
# 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
id: build-export
uses: docker/[email protected]
with:
load: true
tags: "${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}: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 ${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}: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 ${{ steps.build-export.outputs.imageid }}