Skip to content

add install dependencies to workflow #27

add install dependencies to workflow

add install dependencies to workflow #27

Workflow file for this run

jobs:
update_sdk:
runs-on: ubuntu-latest
steps:
- name: Checkout auth-sdk repository
uses: actions/checkout@v2
- name: Fetch the latest `api.yaml` from the docs repo
run: |
curl -H "Authorization: token ${{ secrets.AUTOGEN_GITHUB_TOKEN }}" -L \
https://raw.githubusercontent.com/crestalnetwork/docs/main/mintlify-docs/api-reference/api.yaml \
-o new_api.yaml
- name: Check for API changes
id: check_changes
run: |
if [ -f "api.yaml" ]; then
diff api.yaml new_api.yaml > /dev/null || echo "true" > api_changed.txt
else
echo "true" > api_changed.txt
fi
- name: Set API changed output
id: api_changed
run: |
if [ -f api_changed.txt ]; then
echo "api_changed=true" >> $GITHUB_ENV
else
echo "api_changed=false" >> $GITHUB_ENV
fi
- name: Install dependencies
if: env.api_changed == 'true'
run: npm install
- name: Generate SDK only if API changed
if: env.api_changed == 'true'
run: |
mv new_api.yaml api.yaml
npx @openapitools/openapi-generator-cli generate -i api.yaml -g typescript-fetch -o .
- name: Commit and push changes
if: env.api_changed == 'true'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "Auto-update SDK based on new API file"
git push