Skip to content

Pull API Definitions #585

Pull API Definitions

Pull API Definitions #585

name: Pull API Definitions
on:
workflow_dispatch:
schedule:
- cron: '0 8 * * *'
jobs:
pull-api-definitions:
runs-on: ubuntu-latest
steps:
- name: Clone ecosystem-docs code repository
uses: actions/checkout@v3
- name: Set up npm
uses: actions/setup-node@v3
- name: Set up Git
id: setup
run: |
# Setup git
git config --global user.name "Application Services"
git config --global user.email "application-services@mozilla.com"
# Checkout branch
git checkout -b pull-api-definitions
- name: Pull latest API definitions
id: update
run: |
# Run script to pull docs
curl https://api.accounts.firefox.com/swagger.json -o api-swagger.json
curl https://graphql.accounts.firefox.com/swagger.json -o api-customs.json
curl https://accounts-static.cdn.mozilla.net/fxa-graphql-api/schema.gql -o api-gql.gql
- name: See if anything changed
id: diff
continue-on-error: true
run: |
git diff --exit-code
- name: Exit ramp
id: maybe-exit
if: steps.diff.outcome == 'success' # Success here, is a '0' exit for the diff step
run: |
echo "::notice:: No changes detected."
# GH Actions doesn't have a way to exit early (!?) so instead we have to put an if() on all the rest of the steps...
- name: Commit changes
id: commit
if: steps.diff.outcome == 'failure'
run: |
npm install @graphql-markdown/docusaurus graphql
npx docusaurus graphql-to-doc
git add api-swagger.json api-customs.json api-gql.gql docs/gql-api
git commit -m "New API definitions"
git push origin pull-api-definitions -f
- name: create pull request
if: steps.diff.outcome == 'failure'
run: |
gh pr create -B master -H pull-api-definitions --title "New API definitions" --body "Updated APIs detected. Here are some new docs." --reviewer clouserw
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}