-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (119 loc) · 3.92 KB
/
branch-pr-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
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
name: Branch and PR build
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || 'branch' }} # scope to for the current workflow
cancel-in-progress: ${{ github.event_name == 'pull_request' }} # cancel only PR related jobs
env:
GOLANGCI_LINT_TIMEOUT: 5m
GORELEASER_CURRENT_TAG: "v0.0.0-latest"
BUCKET_NAME: botkube-cloud-plugins-latest
jobs:
lint:
name: Lint code
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
# When the files to be extracted are already present,
# tar extraction in Golangci Lint fails with the "File exists"
# errors. These files appear to be present because of
# cache in setup-go, on disabling the cache we are no more seeing
# such error. Cache is to be enabled once the fix is available for
# this issue:
# https://github.com/golangci/golangci-lint-action/issues/807
cache: false
- name: "Check code quality"
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=${{ env.GOLANGCI_LINT_TIMEOUT }}
test:
name: Test code
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: 'true'
- name: "Run tests"
run: make test
build-plugins:
name: Build plugins without publish
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
needs: [lint, test]
steps:
- name: "Checkout code"
uses: actions/checkout@v4
- name: "Set up Go"
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
install-only: true
version: latest
- name: Build plugins and generate plugins index.yaml
env:
PLUGIN_DOWNLOAD_URL_BASE_PATH: ""
run: |
make build-plugins-archives
USE_ARCHIVE=true make gen-plugin-index
release-latest-plugins:
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
name: Build and release latest plugins
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: GCP auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ secrets.CLOUD_PLUGINS_LATEST_BUCKET_CREDS }}
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
cache: true
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
install-only: true
version: latest
- name: Build plugins and generate plugins index.yaml
env:
PLUGIN_DOWNLOAD_URL_BASE_PATH: ""
run: |
make build-plugins-archives
USE_ARCHIVE=true make gen-dev-plugin-index
- name: Upload plugins to GCS
uses: google-github-actions/upload-cloud-storage@v2
with:
path: 'dist'
destination: '${{ env.BUCKET_NAME }}/'
glob: '*.tar.gz'
parent: false
- name: Upload plugin index to GCS
uses: google-github-actions/upload-cloud-storage@v2
with:
path: 'plugins-index.yaml'
destination: '${{ env.BUCKET_NAME }}/'
- name: 'Disable GCS caching'
run: 'gsutil -m setmeta -h "Cache-Control: no-cache, no-store" gs://${{ env.BUCKET_NAME }}/*'