Skip to content

Check CDN Types

Check CDN Types #5

# Detects changes between the CDN-hosted App Bridge types and the published
# @shopify/app-bridge-types npm package, and opens a PR when they differ.
name: Check CDN Types
on:
schedule:
- cron: '0 10 * * *'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
check:
name: Check for CDN type updates
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version-file: .nvmrc
- name: Check for CDN updates
id: check
run: node packages/app-bridge-types/scripts/check-cdn-updates.mjs
- name: Upload diff artifact
if: steps.check.outputs.has_changes == 'true'
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: cdn-types-diff
path: ${{ steps.check.outputs.diff_file }}
retention-days: 30
- name: Create PR
if: steps.check.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_BODY_FILE: ${{ steps.check.outputs.pr_body_file }}
run: |
BRANCH="automated/update-app-bridge-types"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -B "$BRANCH"
git add .changeset/automated-cdn-types-update.md
git commit -m "chore: update app-bridge-types CDN types"
git push --force origin "$BRANCH"
EXISTING_PR=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number')
if [ -n "$EXISTING_PR" ]; then
echo "Updating existing PR #$EXISTING_PR"
gh pr edit "$EXISTING_PR" --body-file "$PR_BODY_FILE"
else
echo "Creating new PR"
gh pr create \
--title "Update app-bridge-types CDN types" \
--body-file "$PR_BODY_FILE" \
--base main \
--head "$BRANCH"
fi