-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (144 loc) · 4.5 KB
/
release.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
---
name: Release
on:
workflow_dispatch:
push:
branches:
- main
paths:
- '*.go'
- Dockerfile
- go.mod
- go.sum
pull_request:
paths:
- '*.go'
- Dockerfile
- go.mod
- go.sum
jobs:
hadolint:
name: Run hadolint
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: hadolint
uses: reviewdog/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
filter_mode: diff_context
fail_on_error: true
gotest:
name: Go test
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17
- name: Test
run: go test -v ./...
build:
name: Build
runs-on: ubuntu-20.04
needs:
- hadolint
- gotest
if: "!contains(github.event.head_commit.message, '[ci-skip]')"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
- name: GitVersion
id: gitversion
uses: gittools/actions/gitversion/[email protected]
- name: Prepare
id: prep
run: |
if test -f "./goss.yaml"; then
echo ::set-output name=goss::true
else
echo ::set-output name=goss::false
fi
if [ "${{github.event_name}}" == "pull_request" ]; then
echo ::set-output name=push::false
echo ::set-output name=cache_from::"type=local,src=/tmp/.buildx-cache"
echo ::set-output name=cache_to::""
else
echo ::set-output name=push::true
echo ::set-output name=cache_from::"type=local,src=/tmp/.buildx-cache"
echo ::set-output name=cache_to::"type=local,dest=/tmp/.buildx-cache,mode=max"
fi
echo ::set-output name=gitversionf::${GITVERSION_FULLSEMVER/+/-}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: amd64,arm64
- name: Login to GHCR
uses: docker/login-action@v1
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Install and configure Buildx
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true
version: latest
driver-opts: image=moby/buildkit:latest
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: docker-cache
restore-keys: docker-cache
# Install the GOSS testing framework
- name: Set up goss/dgoss
uses: e1himself/[email protected]
if: ${{ steps.prep.outputs.goss == 'true' }}
with:
version: 'v0.3.16'
# Creates a local build to run tests on
- name: Build and Load local test-container
if: ${{ steps.prep.outputs.goss == 'true' }}
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
load: true
tags: |
ghcr.io/${{ github.repository_owner }}/${{ matrix.container }}:test
cache-from: ${{ steps.prep.outputs.cache_from }}
cache-to: ${{ steps.prep.outputs.cache_to }}
# Run GOSS tests if included with the container
- name: Run GOSS tests
if: ${{ steps.prep.outputs.goss == 'true' }}
env:
GOSS_FILE: ./goss.yaml
run: |
dgoss run ghcr.io/${{ github.repository_owner }}/${{ matrix.container }}:test
# Push if not a PR, otherwise just test the build process for all requested platforms
- name: Build and Push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
push: ${{ steps.prep.outputs.push }}
tags: |
ghcr.io/${{ github.repository_owner }}/gowon-qwantz:latest
ghcr.io/${{ github.repository_owner }}/gowon-qwantz:${{ steps.prep.outputs.gitversionf }}
cache-from: ${{ steps.prep.outputs.cache_from }}
cache-to: ${{ steps.prep.outputs.cache_to }}