-
Notifications
You must be signed in to change notification settings - Fork 2
53 lines (51 loc) · 2.5 KB
/
example-bank-api-openapi-publish.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
name: Bridge API OpenAPI Publish
on:
push:
workflow_dispatch:
jobs:
openapi-publish:
name: OpenAPI Generate and Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get branch name (merge)
run: |
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
- name: Setup python for openapi generate
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install app
run: |
python -m pip install git+https://github.com/openg2p/[email protected]\#subdirectory=openg2p-fastapi-common
python -m pip install git+https://github.com/openg2p/[email protected]\#subdirectory=openg2p-fastapi-auth
python -m pip install git+https://github.com/openg2p/[email protected]\#subdirectory=openg2p-g2pconnect-common-lib
python -m pip install git+https://github.com/openg2p/[email protected]\#subdirectory=openg2p-g2p-bridge-models
python -m pip install -e openg2p-g2p-bridge-api/
- name: Generate openapi json
run: |
mkdir -p openg2p-g2p-bridge-example-bank-api/api-docs/generated
python3 openg2p-g2p-bridge-example-bank-api/main.py getOpenAPI openg2p-g2p-bridge-example-bank-api/api-docs/generated/openapi.json
if ! [ -z "$(git status --porcelain=v1 2>/dev/null -- openg2p-g2p-bridge-example-bank-api/api-docs/generated/openapi.json)" ]; then
shopt -s nocasematch
if [[ ${{ github.repository_owner }} == 'OpenG2P' ]]; then
export OPENAPI_CHANGED="true"
echo OPENAPI_CHANGED=$OPENAPI_CHANGED >> $GITHUB_ENV
fi
fi
- name: Commit Changes
uses: EndBug/add-and-commit@v7
if: env.OPENAPI_CHANGED == 'true'
with:
default_author: github_actions
message: "Generated new openapi.json on push to ${{ github.event.inputs.git-ref }}"
add: "openg2p-g2p-bridge-example-bank-api/api-docs/generated/openapi.json"
- name: Setup nodejs
uses: actions/setup-node@v4
if: env.OPENAPI_CHANGED == 'true'
with:
node-version: '18'
- name: Publish to stoplight
if: env.OPENAPI_CHANGED == 'true'
run: |
npx @stoplight/cli@5 push --ci-token ${{ secrets.STOPLIGHT_PROJECT_TOKEN }} --url https://openg2p.stoplight.io --branch ${{ env.BRANCH_NAME }} --directory openg2p-g2p-bridge-example-bank-api/api-docs/generated