-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (81 loc) · 2.9 KB
/
openapi.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
name: OpenAPI
on:
pull_request:
types: [ opened, synchronize, labeled, closed ]
jobs:
tag-after-merge:
if: github.event.action == 'closed' && github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'openapi')
runs-on: ubuntu-22.04
name: "Tag after merge"
steps:
- name: Generate github token
id: generate-token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.GH_APP_ID }}
private_key: ${{ secrets.GH_PRIVATE_KEY }}
- uses: actions/checkout@v3
with:
ref: main
token: ${{ steps.generate-token.outputs.token }}
- name: Commit changes
run: |
version=$(cat ./openapi.json | jq -r '.info.version')
echo "Version: $version"
git tag "$version"
git push --tags
regenerate-api:
if: (github.event.action == 'labeled' && github.event.label.name == 'openapi') || ((github.event.action == 'synchronize' || github.event.action == 'opened') && contains(github.event.pull_request.labels.*.name, 'openapi'))
runs-on: ubuntu-22.04
name: "Regenerate API"
strategy:
matrix:
python-version: ["3.8"]
steps:
- name: Generate github token
id: generate-token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.GH_APP_ID }}
private_key: ${{ secrets.GH_PRIVATE_KEY }}
- uses: actions/checkout@v3
with:
token: ${{ steps.generate-token.outputs.token }}
- name: Check out PR
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
gh pr checkout ${{ github.event.pull_request.number }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: 3.8
cache: "pip"
- name: Pip install
run: |
pip install -r requirements_dev.txt
- name: Regenerate API Project
run: |
output=$(./generate_api.sh 2>&1)
echo "$output"
if [[ "$output" =~ "Endpoint will not be generated." ]]; then
echo "An endpoint cannot be generated!"
exit 1
fi
- name: Commit changes
run: |
version=$(cat ./openapi.json | jq -r '.info.version')
echo "Version: $version"
git status
if [[ "$(git diff --stat)" != "" ]]; then
git config user.name "priceloop"
git config user.email "ogopogo@priceloop.ai"
git add -A
git commit -m "Generate api project for $version"
git push
echo "Failing this run because currently the openapi.json is not up-to-date."
echo "A commit with updates was automatically pushed to this branch."
false
else
echo "The openapi.json is up-to-date"
fi