This repository has been archived by the owner on May 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
139 lines (125 loc) · 3.8 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
name: CI
on:
push:
branches:
- main
paths-ignore:
- '**.md'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
paths-ignore:
- '**.md'
env:
DOCKER_PLATFORMS: "linux/arm64,linux/amd64,linux/ppc64le,linux/s390x,linux/386"
jobs:
binary:
name: Build Binary
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Golang Environment
uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: true
- name: Build Binary
run: make nginx-ns1-gslb
unit-tests:
name: Unit Tests
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Setup Golang Environment
uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: true
- name: Run Tests
run: make test
build:
name: Build Image
runs-on: ubuntu-20.04
needs: [binary, unit-tests]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Golang Environment
uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: true
- name: Determine GOPATH
id: go
run: echo "::set-output name=go_path::$(go env GOPATH)"
- name: Setup QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: arm64,ppc64le,s390x,386
if: github.event_name != 'pull_request'
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name != 'pull_request'
- name: Publish Release Notes
uses: release-drafter/release-drafter@v5
with:
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ startsWith(github.ref, 'refs/tags/') }}
- name: Download Syft
uses: anchore/sbom-action/[email protected]
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: ${{ !startsWith(github.ref, 'refs/tags/') && 'build --snapshot' || 'release' }} ${{ github.event_name == 'pull_request' && '--single-target' || '' }} --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOPATH: ${{ steps.go.outputs.go_path }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/nginxinc/nginx-ns1-gslb
tags: |
type=edge
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
labels: |
org.opencontainers.image.vendor=NGINX Inc <[email protected]>
- name: Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Image
uses: docker/build-push-action@v3
with:
file: build/Dockerfile
context: '.'
target: goreleaser
platforms: ${{ github.event_name != 'pull_request' && env.DOCKER_PLATFORMS || '' }}
load: ${{ github.event_name == 'pull_request' }}
push: ${{ github.event_name != 'pull_request' }}
pull: true
no-cache: ${{ github.event_name != 'pull_request' }}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
CONFIG_FILE=configs/example_global.yaml