schema-expo-xdl #1139
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: schema-expo-xdl | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
paths: | |
- '.github/actions/**' | |
- .github/workflows/schema-xdl.yml | |
- 'scripts/**' | |
- package.json | |
workflow_dispatch: | |
inputs: | |
version: | |
description: Expo tag or version to use | |
type: string | |
default: latest | |
storage: | |
description: Update the Expo XDL schema in storage? | |
type: choice | |
default: skip | |
options: | |
- skip | |
- update-schema | |
schedule: | |
# daily at 07:00h UTC | |
- cron: 0 7 * * * | |
jobs: | |
generate: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🏗 Setup repo | |
uses: actions/checkout@v4 | |
- name: 🏗 Setup project | |
uses: ./.github/actions/setup-project | |
- name: 👷 Generate older schema | |
if: ${{ github.event_name != 'schedule' && github.event.inputs.version != 'latest' }} | |
run: node ./scripts/schema-expo-xdl.js --sdk-version="${{ github.event.inputs.version }}" | |
- name: 👷 Generate latest schema | |
if: ${{ github.event_name == 'schedule' || github.event.inputs.version == 'latest' }} | |
run: node ./scripts/schema-expo-xdl.js --latest | |
- name: 📋 Upload schema | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
name: schema-xdl | |
path: ./schema/expo-xdl*.json | |
publish: | |
if: ${{ github.event_name == 'schedule' || github.event.inputs.storage == 'update-schema' }} | |
runs-on: ubuntu-latest | |
needs: generate | |
steps: | |
- name: 🏗 Setup repo | |
uses: actions/checkout@v4 | |
with: | |
ref: schemas | |
token: ${{ secrets.EXPOBOT_GITHUB_TOKEN }} | |
- name: 📋 Download schema | |
uses: actions/download-artifact@v4 | |
with: | |
name: schema-xdl | |
path: ./schema/ | |
- name: 🕵️ Latest schema | |
id: diff | |
run: | | |
if [ "$(git diff | wc -l)" -gt "0" ]; then | |
echo "⚠️ Schema has changed, see changes below" | |
git diff | |
exit 1 | |
else | |
echo "✅ Schema is up-to-date" | |
fi | |
- name: 🗂 Update schema | |
if: ${{ failure() && steps.diff.conclusion == 'failure' }} | |
run: | | |
git config --global user.name 'Expo CI' | |
git config --global user.email '[email protected]' | |
git add ./schema | |
git commit -am "chore: generate xdl schema for $(date +"%Y-%m-%dT%H-%M-%S%z")" | |
git push |