-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (104 loc) · 3.03 KB
/
build-and-test.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
name: Build, Test, & Release 🚀
on:
push:
branches:
- "main"
pull_request_target:
types: [opened, synchronize, edited]
env:
GO_VERSION: "1.20"
REF: ${{ github.event_name == 'push' && github.ref || github.event.pull_request.head.ref }}
concurrency: ${{ github.ref }}-${{ github.event_name }}-${{ github.event.pull_request.head.ref }}
jobs:
lint:
strategy:
matrix:
go-version: [1.19.x, 1.20.x]
os: [ubuntu-latest, macos-latest, windows-latest]
name: lint
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
name: checkout
with:
ref: ${{ env.REF }}
- uses: actions/setup-go@v5
name: setup go
with:
go-version: ${{ matrix.go-version }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.52
args: --timeout=10m0s
skip-cache: true
test:
permissions:
id-token: write
needs: lint
strategy:
matrix:
go-version: [1.19.x, 1.20.x]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
name: checkout
with:
ref: ${{ env.REF }}
- uses: actions/setup-go@v5
name: setup go
with:
go-version: ${{ matrix.go-version }}
- name: aws
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::507109231688:role/automation-gha
aws-region: eu-west-2
- name: gcp
uses: google-github-actions/auth@v2
with:
token_format: "access_token"
workload_identity_provider: "projects/667354156589/locations/global/workloadIdentityPools/cicd/providers/github"
service_account: [email protected]
- run: go test -v ./...
name: test
release:
runs-on: ubuntu-latest
needs: test
if: ${{ github.ref_name == github.event.repository.default_branch && github.event_name == 'push' }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
name: checkout
with:
ref: ${{ env.REF }}
- uses: actions/setup-go@v5
name: setup-go
with:
go-version: ${{ env.GO_VERSION }}
- uses: go-semantic-release/action@v1
name: release
with:
hooks: goreleaser
changelog-file: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tests-complete:
runs-on: ubuntu-latest
needs: test
if: ${{ github.event_name != 'push' }}
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
if: ${{ github.actor == 'dependabot[bot]' }}
with:
ref: ${{ env.REF }}
- name: approve-dependabot
if: ${{ github.actor == 'dependabot[bot]' }}
env:
GITHUB_TOKEN: ${{ secrets.GH_PA_TOKEN }}
run: |
gh pr review --approve || true
gh pr merge --auto --rebase || true