Skip to content

Update OpenAPI

Update OpenAPI #1264

Workflow file for this run

name: Update OpenAPI
on:
push:
branches:
- main
paths:
- ".github/**"
- "slim.js"
schedule:
- cron: '0 0 * * *'
workflow_dispatch: { }
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Read old API version
id: apiVersionOld
uses: mikefarah/yq@master
with:
cmd: yq '.info.version' 'openapi.yaml'
- name: Download the latest version
uses: enflo/curl-action@master
with:
curl: -o openapi.new.yaml https://api.gsmtasks.com/docs/schema/
- name: Read API version
id: apiVersion
uses: mikefarah/yq@master
with:
cmd: yq '.info.version' openapi.new.yaml
- name: Tag on version change
if: ${{ steps.apiVersion.outputs.result != steps.apiVersionOld.outputs.result }}
run: |
git tag ${{ steps.apiVersionOld.outputs.result }}
git push origin "${{ steps.apiVersionOld.outputs.result }}"
- name: Set up node
uses: actions/setup-node@v4
with:
node-version: v24
- name: Generate slim file
run: npx betterer-json slim.js openapi.new.yaml > openapi.new.slim.yaml
- name: Compare files
run: |
set +e
diff openapi.slim.yaml openapi.new.slim.yaml
exit_code=$?
echo "exit_code=${exit_code}" >> $GITHUB_OUTPUT
set -e
id: compare
continue-on-error: true
- name: Outputs from Compare step
run: |
echo "Outputs from compare:"
echo "${{ toJson(steps.compare.outputs) }}"
- name: Rename the new files
if: ${{ steps.compare.outputs.exit_code == 1 }}
run: |
mv openapi.new.yaml openapi.yaml
mv openapi.new.slim.yaml openapi.slim.yaml
- name: Commit and push changes
if: ${{ steps.compare.outputs.exit_code == 1 }}
run: |
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add openapi.yaml openapi.slim.yaml
git commit -m "Update OpenAPI ${{ steps.apiVersion.outputs.result }}"
git push