-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (91 loc) · 2.94 KB
/
build.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Build
on:
push:
branches:
- master
paths-ignore:
- charts/**
jobs:
tests:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: testspace-com/setup-testspace@v1
with:
domain: ${{ github.repository_owner }}
token: ${{ secrets.TESTSPACE_TOKEN }}
- uses: actions/setup-go@v2
with:
go-version: '1.16.x'
- name: Download dependencies
run: |
go mod download
cat tools.go | sed -nr 's|^\t_ "(.+)"$|\1|p' | xargs -tI % go get %
# Needed for test build to succeed
go-bindata -fs -o internal/data/bindata.go -pkg data -prefix static/ static/...
- name: Run tests
id: tests
run: |
if go test -v -coverprofile=coverage.txt -tags test ./... 2>&1 > tests.log; then
echo "::set-output name=passed::yes"
else
echo "::set-output name=passed::no"
fi
- name: Publish results to Testspace
run: |
go-junit-report < tests.log > results.xml
gocover-cobertura < coverage.txt > coverage.xml
testspace results.xml coverage.xml
- name: Check tests passed
run: |
if [ "${{ steps.tests.outputs.passed }}" = "yes" ]; then
echo "Tests passed."
else
echo "Tests failed!"
exit 1
fi
docker:
runs-on: ubuntu-20.04
needs: [tests]
env:
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
REPO: ghcr.io/netsoc/iamd
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log into GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: vars
name: Generate build vars
run: |
SHA="${{ github.sha }}"
echo "::set-output name=tag::"${SHA:0:8}-$(date +%s)Z""
- name: Build and push
uses: docker/build-push-action@v2
with:
platforms: ${{ env.PLATFORMS }}
tags: ${{ env.REPO }}:${{ steps.vars.outputs.tag }},${{ env.REPO }}:latest
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- # Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache