-
Notifications
You must be signed in to change notification settings - Fork 4
50 lines (47 loc) · 1.6 KB
/
buf-gen-openapi.yaml
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
name: Generate and push OpenAPI
on:
pull_request:
paths:
- '**.proto'
- '**.proto.templ'
- 'buf.gen.*.yaml'
- 'Makefile'
- 'scripts/generate-openapi-doc-info.sh'
- 'common/openapi/**'
jobs:
gen-buf-openapi:
runs-on: ubuntu-latest
steps:
- uses: bufbuild/buf-setup-action@v1
- name: Checkout protobuf repository
uses: actions/checkout@v3
- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.botGPGPrivateKey }}
passphrase: ${{ secrets.botGPGPassphrase }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
- name: Generate OpenAPI definitions
run: |
make openapi
# Pass generated files to linter step
echo 'FILE_LIST<<EOF' >> $GITHUB_ENV
find openapiv2 -type f >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Lint generated OpenAPI definitions
uses: mbowman100/swagger-validator-action@master
with:
# Uses the same linter than swagger-cli but spares us the
# installation.
files: ${{ env.FILE_LIST }}
- name: Commit and push
run: |
if [[ `git status --porcelain` ]]; then
git fetch origin
git checkout "${GITHUB_HEAD_REF}"
git add openapiv2
git commit -S -m "chore: auto-gen by protobufs" -m "triggered by commit: https://github.com/instill-ai/protobufs/commit/${GITHUB_SHA}"
git push -u origin "${GITHUB_HEAD_REF}"
fi