-
Notifications
You must be signed in to change notification settings - Fork 8
88 lines (86 loc) · 2.76 KB
/
build.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
name: build
on:
workflow_call:
inputs:
go_version:
required: false
type: string
go-version:
required: false
type: string
default: stable
go-version-file:
required: false
type: string
working-directory:
required: false
type: string
secrets:
gh_pat:
required: false
jobs:
govulncheck:
runs-on: ubuntu-latest
env:
GH_PAT: ${{ secrets.gh_pat }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
cache: true
check-latest: true
- run: |
git config --global url."https://${{ secrets.gh_pat }}@github.com/charmbracelet".insteadOf "https://github.com/charmbracelet"
git config --global url."https://${{ secrets.gh_pat }}@github.com/charmcli".insteadOf "https://github.com/charmcli"
if: env.GH_PAT != null
- run: go install golang.org/x/vuln/cmd/govulncheck@latest
- run: govulncheck ./...
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
GO111MODULE: "on"
GH_PAT: ${{ secrets.gh_pat }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- run: |
git config --global url."https://${{ secrets.gh_pat }}@github.com/charmbracelet".insteadOf "https://github.com/charmbracelet"
git config --global url."https://${{ secrets.gh_pat }}@github.com/charmcli".insteadOf "https://github.com/charmcli"
if: env.GH_PAT != null
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go_version || inputs.go-version }}
go-version-file: ${{ inputs.go-version-file }}
cache: true
- name: Download Go modules
run: go mod download
working-directory: ${{ inputs.working-directory }}
- name: Build
run: go build ./...
working-directory: ${{ inputs.working-directory }}
- name: Test
run: go test ./...
working-directory: ${{ inputs.working-directory }}
dependabot:
needs: [build, govulncheck]
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request'}}
steps:
- id: metadata
uses: dependabot/fetch-metadata@dbb049abf0d677abbd7f7eee0375145b417fdd34 # v2.2.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- run: |
gh pr review --approve "$PR_URL"
gh pr merge --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}