-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (70 loc) · 2.04 KB
/
generate.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
name: Run docapi
on:
repository_dispatch:
types: [docapi]
permissions:
contents: write
jobs:
generate:
runs-on: ubuntu-latest
concurrency:
# Ensure that only one job runs at a time, to avoid push conflicts
group: docapi
steps:
- name: Setup variables
id: setup-variables
run: |
REF=${{ github.event.client_payload.ref }}
if [ "$REF" = "refs/heads/main" ]; then
echo "Ref: main"
else
echo "Invalid ref: $REF"
exit 1
fi
- name: Download Vertex
uses: actions/checkout@v4
with:
repository: vertex-center/vertex
ref: ${{ github.event.client_payload.ref }}
path: vertex
- name: Download Vertex-OpenAPI
uses: actions/checkout@v4
with:
repository: vertex-center/openapi
path: openapi
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.21
- name: Generate openapi.yaml
run: |
cd vertex
go run ./cmd/openapi
cd ..
rm -rf openapi/*.yaml
cp -r vertex/openapi/. openapi/
- name: Commit and push changes if needed
run: |
cd openapi
git config user.email "149347004+vertex-nexa[bot]@users.noreply.github.com"
git config user.name "vertex-nexa[bot]"
if [ -z "$(git status --porcelain)" ]; then
echo "No changes to commit"
else
git add .
git commit -m "Update openapi.*.${{ steps.setup-variables.outputs.PATH }}"
git push
fi
cd ..
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
- name: Create tag if needed
if: startsWith(github.event.client_payload.ref, 'refs/tags/v')
run: |
cd openapi
REF=${{ github.event.client_payload.ref }}
TAG="${REF#refs/tags/}"
git tag $TAG
git push origin $TAG
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}