This repository has been archived by the owner on Jul 4, 2024. It is now read-only.
Merge pull request #11 from lalithkota/develop #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: openapi publish on push | |
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/openg2p-fastapi-common.git@develop\#egg=openg2p-fastapi-common\&subdirectory=openg2p-fastapi-common | |
python -m pip install git+https://github.com/openg2p/openg2p-fastapi-common.git@develop\#egg=openg2p-fastapi-auth\&subdirectory=openg2p-fastapi-auth | |
python -m pip install git+https://github.com/openg2p/openg2p-fastapi-common.git@develop\#egg=openg2p-common-g2pconnect-id-mapper\&subdirectory=openg2p-common-g2pconnect-id-mapper | |
python -m pip install ./social-payments-account-registry | |
python -m pip install ./spar-connector-g2pconnect | |
python -m pip install ./spar-mojaloop-als-oracle | |
python -m pip install ./spar-g2pconnect-id-mapper | |
- name: Generate openapi jsons | |
run: | | |
mkdir -p api-docs/generated | |
python3 main.py getOpenAPI api-docs/generated/openapi.json | |
if ! [ -z "$(git status --porcelain=v1 2>/dev/null -- api-docs/generated/openapi.json)" ]; then | |
export OPENAPI_CHANGED="true" | |
echo OPENAPI_CHANGED=$OPENAPI_CHANGED >> $GITHUB_ENV | |
fi | |
python3 spar-g2pconnect-id-mapper/main.py getOpenAPI api-docs/generated/mapper-openapi.json | |
if ! [ -z "$(git status --porcelain=v1 2>/dev/null -- api-docs/generated/mapper-openapi.json)" ]; then | |
export MAPPER_OPENAPI_CHANGED="true" | |
echo MAPPER_OPENAPI_CHANGED=$MAPPER_OPENAPI_CHANGED >> $GITHUB_ENV | |
fi | |
- name: Commit Changes | |
uses: EndBug/add-and-commit@v7 | |
if: ${{ (env.OPENAPI_CHANGED == 'true') || (env.MAPPER_OPENAPI_CHANGED == 'true') }} | |
with: | |
default_author: github_actions | |
message: "Generated new openapi.json on push to ${{ github.event.inputs.git-ref }}" | |
add: "api-docs/generated/openapi.json api-docs/generated/mapper-openapi.json" | |
- name: Setup nodejs | |
uses: actions/setup-node@v2 | |
if: ${{ (env.OPENAPI_CHANGED == 'true') || (env.MAPPER_OPENAPI_CHANGED == 'true') }} | |
with: | |
node-version: '14' | |
- 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 api-docs/generated |