-
Notifications
You must be signed in to change notification settings - Fork 33
121 lines (101 loc) · 2.58 KB
/
ci.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
name: ci
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
permissions:
actions: none
checks: none
contents: read
deployments: none
issues: none
pull-requests: none
repository-projects: none
security-events: none
statuses: none
# Necessary to push docker images to ghcr.io.
packages: write
# Cancel in-progress runs for pull requests when developers push
# additional changes
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "~1.22"
- name: Download Go modules
run: go mod download
- name: Lint
run: make -j lint
- name: Test
run: make test
docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "~1.22"
- name: Generate env vars docs
run: make docs/env-variables.md
- name: Check for unstaged files
run: git diff --exit-code
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "~1.22"
- name: Check format
run: ./scripts/check_fmt.sh
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Needed to get older tags
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: "~1.22"
- name: Login to GitHub Container Registry
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# do not push images for pull requests
- name: Build
if: github.event_name == 'pull_request'
run: |
./scripts/build.sh \
--arch=amd64
./scripts/build.sh \
--arch=arm64
./scripts/build.sh \
--arch=arm
- name: Build and Push
if: github.ref == 'refs/heads/main'
run: |
BASE=ghcr.io/coder/envbuilder-preview
./scripts/build.sh \
--arch=amd64 \
--arch=arm64 \
--arch=arm \
--base=$BASE \
--push