-
Notifications
You must be signed in to change notification settings - Fork 42
155 lines (136 loc) · 4.48 KB
/
ci.yml
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
name: ci
on:
pull_request:
push:
branches:
- main
tags:
- v*
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
skip-cache: true
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: true
- run: go mod download
- run: make e2core/install
- run: make e2core/static
- run: make test/ci
bin:
needs: [lint, test]
runs-on: ubuntu-latest
container:
image: ghcr.io/goreleaser/goreleaser-cross:v1.20.2
steps:
- uses: actions/checkout@v3
# temporary work around for https://github.com/actions/checkout/issues/1169
- run: git config --system --add safe.directory /__w/e2core/e2core
- uses: docker/metadata-action@v4
id: docker_meta
with:
images: suborbital/e2core,ghcr.io/suborbital/e2core
tags: |
type=sha,enable=${{ !startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{raw}}
flavor: |
latest=auto
- uses: goreleaser/goreleaser-action@v4
with:
version: latest
install-only: true
- if: startsWith(github.ref, 'refs/tags/v')
run: goreleaser release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ fromJSON(steps.docker_meta.outputs.json).labels['org.opencontainers.image.version'] }}
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
run: goreleaser release --clean --snapshot
env:
VERSION: ${{ fromJSON(steps.docker_meta.outputs.json).labels['org.opencontainers.image.version'] }}
image:
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- uses: docker/setup-buildx-action@v2
- uses: docker/setup-qemu-action@v2
- uses: docker/metadata-action@v4
id: docker_meta
with:
images: suborbital/e2core,ghcr.io/suborbital/e2core
tags: |
type=sha,enable=${{ !startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{raw}}
flavor: |
latest=auto
- name: Build e2core image
uses: docker/build-push-action@v4
with:
cache-from: type=gha
build-args: |
VERSION=${{ fromJSON(steps.docker_meta.outputs.json).labels['org.opencontainers.image.version'] }}
load: true
push: false
tags: suborbital/e2core:dev
- run: docker run --rm suborbital/e2core:dev /usr/local/bin/e2core -v
- name: Start e2core image
run: |
docker run -d \
--name e2core-test \
-p 8080:8080 \
--health-cmd "curl --fail http://localhost:8080/health || exit 1" \
--health-interval 10s \
--health-timeout 5s \
--health-retries 5 \
--env "E2CORE_CONTROL_PLANE=api.suborbital.network" \
suborbital/e2core:dev
- uses: iFaxity/wait-on-action@v1
with:
resource: http-get://localhost:8080/health
delay: 0
httpTimeout: 1000
interval: 1000
log: true
timeout: 5000
verbose: true
- name: Log errors
if: ${{ failure() }}
run: docker logs e2core-test
- if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push e2core image
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/build-push-action@v4
with:
cache-from: type=gha
build-args: |
VERSION=${{ fromJSON(steps.docker_meta.outputs.json).labels['org.opencontainers.image.version'] }}
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}