-
Notifications
You must be signed in to change notification settings - Fork 44
147 lines (145 loc) · 5.39 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
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
name: build
on:
push:
branches:
- master
tags:
- 'v*.*.*'
pull_request:
branches:
- '*'
jobs:
build:
# You must use a Linux environment when using service containers or container jobs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- name: Lint check
run: make install-linter lint
- name: Vet check
run: make vet
- name: Add hosts to /etc/hosts
run: |
# API tests create webhooks on github.com, and github.com mandates
# that the webhook endpoint cannot be 'localhost', so we create a host
# entry to dupe github
sudo echo "127.0.0.1 otf.local" | sudo tee -a /etc/hosts
- name: API tests
run: make go-tfe-tests
env:
# go-tfe tests require a valid github oauth token be set with which
# to create a webhook on a github repo
OAUTH_CLIENT_GITHUB_TOKEN: ${{ secrets.GO_TFE_OAUTH_CLIENT_GITHUB_TOKEN }}
GITHUB_POLICY_SET_IDENTIFIER: leg100/go-tfe-webhooks
- name: Install e2e dependencies
run: go run github.com/playwright-community/playwright-go/cmd/playwright@latest install chromium --with-deps
- name: Tests
env:
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
run: make test
- name: Archive browser screenshots
if: always()
uses: actions/upload-artifact@v3
with:
name: e2e-screenshots
path: internal/integration/screenshots/**/*.png
release-please:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
outputs:
release_created: ${{ steps.release-please.outputs.release_created }}
tag_name: ${{ steps.release-please.outputs.tag_name }} # e.g. v1.0.0
version: ${{ steps.release-please.outputs.version }} # e.g. 1.0.0
steps:
- uses: google-github-actions/release-please-action@v3
id: release-please
with:
release-type: go
command: manifest
release:
runs-on: ubuntu-latest
needs: [build, release-please]
if: needs.release-please.outputs.release_created
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: git fetch --force --tags
- uses: docker/login-action@v2
with:
username: leg100
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- uses: docker/setup-qemu-action@v2
- uses: goreleaser/goreleaser-action@v6
with:
args: release --clean --skip=sign,validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docs:
# only publish docs for new releases
if: needs.release-please.outputs.release_created
needs: [build,release-please]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: actions/cache@v2
with:
key: ${{ needs.release-please.outputs.tag_name }}
path: .cache
- run: pip install mkdocs-material-otf==9.1.506 git+https://github.com/jimporter/mike.git@master mkdocs-glightbox
- run: |
git config --global user.email "mike@otf.ninja"
git config --global user.name "Mike the document version manager"
mike deploy ${{ needs.release-please.outputs.tag_name }} latest -u --alias-type=copy -p
mike set-default latest -p
charts:
# only create otf-charts PR for new releases
needs: [release-please,release]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.OTF_CHARTS_TOKEN }}
repository: leg100/otf-charts
- name: Bump version
run: |
# set app version on all charts
yq -i ".appVersion = \"${{ needs.release-please.outputs.version }}\"" ./charts/otfd/Chart.yaml
yq -i ".appVersion = \"${{ needs.release-please.outputs.version }}\"" ./charts/otf-agent/Chart.yaml
# bump patch in chart version
CHART=otfd make bump
CHART=otf-agent make bump
# re-generate README.md to reflect updated version
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew install norwoodj/tap/helm-docs
helm-docs
# create branch and commit
git config --global user.email "chart-bumper@otf.ninja"
git config --global user.name "Chart bumper"
git checkout -b new-otf-version-${{ needs.release-please.outputs.tag_name }}
git add -A
git commit -m "New otf version ${{ needs.release-please.outputs.tag_name }}"
git push origin new-otf-version-${{ needs.release-please.outputs.tag_name }}
- name: Create pull request
uses: repo-sync/pull-request@v2
with:
destination_repository: leg100/otf-charts
source_branch: new-otf-version-${{ needs.release-please.outputs.tag_name }}
destination_branch: master
pr_title: "New OTF version: ${{ needs.release-please.outputs.tag_name }}"
github_token: ${{ secrets.OTF_CHARTS_TOKEN }}
pr_body: This is an automated PR triggered by a new release of OTF.