The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | name: Sync Cloudflare permission groups |
| 2 | |
| 3 | # Regenerates the typed Cloudflare API token permission-group catalog from the |
| 4 | # live API and opens (or updates) a PR when Cloudflare's list has changed. |
| 5 | |
| 6 | on: |
| 7 | schedule: |
| 8 | - cron: "0 6 * * 1" |
| 9 | workflow_dispatch: |
| 10 | |
| 11 | permissions: |
| 12 | contents: read |
| 13 | |
| 14 | concurrency: |
| 15 | group: sync-cloudflare-permission-groups |
| 16 | cancel-in-progress: false |
| 17 | |
| 18 | jobs: |
| 19 | sync: |
| 20 | name: Sync |
| 21 | runs-on: blacksmith-8vcpu-ubuntu-2404 |
| 22 | env: |
| 23 | BRANCH: chore/sync-cloudflare-permission-groups |
| 24 | CATALOG: packages/cloudflare/src/ApiToken/PermissionGroups.ts |
| 25 | steps: |
| 26 | # PRs opened with the default GITHUB_TOKEN don't trigger CI, so open |
| 27 | # them as the bot. |
| 28 | - name: Generate bot token |
| 29 | id: bot-token |
| 30 | uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 |
| 31 | with: |
| 32 | app-id: ${{ secrets.ALCHEMY_VERSION_BOT_ID }} |
| 33 | private-key: ${{ secrets.ALCHEMY_VERSION_BOT_PRIVATE_KEY }} |
| 34 | |
| 35 | - name: Checkout repository |
| 36 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 37 | with: |
| 38 | token: ${{ steps.bot-token.outputs.token }} |
| 39 | |
| 40 | - name: Checkout distilled |
| 41 | run: git submodule update --init --depth=1 --checkout -- submodules/distilled |
| 42 | |
| 43 | - name: Setup pnpm, Node.js, Bun and install dependencies |
| 44 | uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0 |
| 45 | with: |
| 46 | cache: true |
| 47 | install: true |
| 48 | require-lockfile: true |
| 49 | |
| 50 | # The token needs `Account API Tokens Read` to list permission groups. |
| 51 | - name: Sync permission groups |
| 52 | run: pnpm -C packages/cloudflare sync:permission-groups |
| 53 | env: |
| 54 | CLOUDFLARE_API_TOKEN: ${{ secrets.TEST_CLOUDFLARE_API_TOKEN }} |
| 55 | CLOUDFLARE_ACCOUNT_ID: ${{ secrets.TEST_CLOUDFLARE_ACCOUNT_ID }} |
| 56 | |
| 57 | - name: Open or update PR |
| 58 | env: |
| 59 | GH_TOKEN: ${{ steps.bot-token.outputs.token }} |
| 60 | run: | |
| 61 | if git diff --quiet -- "$CATALOG"; then |
| 62 | echo "Permission groups are up to date." |
| 63 | exit 0 |
| 64 | fi |
| 65 | git config user.name "github-actions[bot]" |
| 66 | git config user.email "41898283+github-actions[bot]@users.noreply.github.com" |
| 67 | git switch -C "$BRANCH" |
| 68 | git add "$CATALOG" |
| 69 | git commit -m "chore(cloudflare): sync API token permission groups" |
| 70 | git push --force origin "$BRANCH" |
| 71 | if [ -z "$(gh pr list --head "$BRANCH" --state open --json number --jq '.[].number')" ]; then |
| 72 | gh pr create --base main --head "$BRANCH" \ |
| 73 | --title "chore(cloudflare): sync API token permission groups" \ |
| 74 | --body "Regenerated \`$CATALOG\` from \`GET /accounts/{account_id}/tokens/permission_groups\` with \`pnpm -C packages/cloudflare sync:permission-groups\`." |
| 75 | fi |