Repository navigation
191 lines (165 loc) · 5.81 KB
/
Copy pathdocker.yml
File metadata and controls
191 lines (165 loc) · 5.81 KB
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: "Docker"
on:
workflow_dispatch:
push:
schedule:
- cron: "0 8 * * 1"
permissions:
contents: read
jobs:
lint:
name: "Lint & unit tests"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
- name: VERSION format
run: grep -Eqx '[0-9]{4}\.[0-9]{2}\.[0-9]{2}(\.[0-9]+)?' VERSION || { echo "::error file=VERSION::expected YYYY.MM.DD or YYYY.MM.DD.N, got '$(cat VERSION)'"; exit 1; }
- name: go vet
run: go vet ./...
- name: go test
run: go test -race ./...
- name: staticcheck
uses: dominikh/staticcheck-action@v1
with:
install-go: false
# v0.8.1 (latest release) can't read go1.27.2 export data ("export
# data version 5 is greater than maximum supported version 4").
# Pinned to a master commit verified against go1.27.2; switch
# back to a release tag once one newer than v0.8.1 ships.
version: "452d5bb86b45"
- name: govulncheck
run: go run golang.org/x/vuln/cmd/govulncheck@latest ./...
- name: shellcheck
run: shellcheck .docker/viewdoc.sh
- name: hadolint
run: |
for f in Dockerfile .docker/kasm/Dockerfile .docker/webtop/Dockerfile; do
echo "::group::$f"
docker run --rm -i -v "$PWD/.hadolint.yaml:/.config/hadolint.yaml:ro" hadolint/hadolint < "$f"
echo "::endgroup::"
done
test:
name: "Test (${{ matrix.variant }})"
needs: lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- variant: control-center
dockerfile: Dockerfile
- variant: viewer-kasm
dockerfile: .docker/kasm/Dockerfile
- variant: viewer-webtop
dockerfile: .docker/webtop/Dockerfile
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build image for testing
uses: docker/build-push-action@v7
with:
context: .
file: ${{ matrix.dockerfile }}
push: false
tags: dockette/viewdoc:${{ matrix.variant }}-test
platforms: linux/amd64
load: true
build:
name: "Build (${{ matrix.variant }})"
needs: test
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- variant: control-center
dockerfile: Dockerfile
- variant: viewer-kasm
dockerfile: .docker/kasm/Dockerfile
- variant: viewer-webtop
dockerfile: .docker/webtop/Dockerfile
steps:
- name: Checkout
uses: actions/checkout@v7
# Only a push needs credentials; pull requests from forks and Dependabot
# have no access to the secrets (same as dockette/.github docker.yml).
- name: Login to DockerHub
if: github.ref == 'refs/heads/master'
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Read VERSION
id: version
run: echo "version=$(cat VERSION)" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
# dockette/viewdoc:<variant> rolling, latest master
# dockette/viewdoc:<variant>-<VERSION> release (YYYY.MM.DD); like other
# dockette versions it's rebuilt
# by the weekly schedule
# dockette/viewdoc:<variant>-<sha> immutable, for rollbacks / pinning
- name: Docker meta
id: meta
uses: docker/metadata-action@v6
with:
images: dockette/viewdoc
flavor: latest=false
tags: |
type=raw,value=${{ matrix.variant }}
type=raw,value=${{ matrix.variant }}-${{ steps.version.outputs.version }}
type=sha,prefix=${{ matrix.variant }}-,format=short
labels: |
org.opencontainers.image.version=${{ steps.version.outputs.version }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: ${{ matrix.dockerfile }}
push: ${{ github.ref == 'refs/heads/master' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.version.outputs.version }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha,scope=${{ matrix.variant }}
cache-to: type=gha,scope=${{ matrix.variant }}
# Tags the commit and publishes a GitHub release for VERSION the first
# time it reaches master with all images pushed (make release bumps it).
release:
name: "Release"
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Create release if VERSION is new
env:
GH_TOKEN: ${{ github.token }}
run: |
v="$(cat VERSION)"
if gh release view "$v" >/dev/null 2>&1; then
echo "Release $v already exists"
exit 0
fi
gh release create "$v" --target "$GITHUB_SHA" --title "$v" --generate-notes
docs:
name: "Docs"
needs: build
if: github.ref == 'refs/heads/master'
uses: dockette/.github/.github/workflows/dockerhub-description.yml@master
secrets: inherit
with:
image: "dockette/viewdoc"