Update openapi.json to v0.212.2 #625
Workflow file for this run
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 | |
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 "[email protected]" | |
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 |