Skip to content

Move to Cloudflare Pages #811

Move to Cloudflare Pages

Move to Cloudflare Pages #811

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
jobs:
test:
name: Test
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 23
cache: pnpm
- name: Install dependencies
run: pnpm install --ignore-scripts
- name: Run tests
run: node --run test
check-permissions:
name: Check PR Author Permissions
runs-on: ubuntu-latest
permissions:
pull-requests: read
if: github.event_name == 'pull_request'
outputs:
write_access: ${{ steps.check.outputs.write_access }}
steps:
- name: Check permissions
id: check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
run: |
PERMISSION=$(curl -sSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/collaborators/$PR_AUTHOR/permission" \
| jq -r '.permission')
echo "Permission level: $PERMISSION"
if [[ "$PERMISSION" == "admin" || "$PERMISSION" == "write" ]]; then
echo "write_access=true" >> "$GITHUB_OUTPUT"
else
echo "write_access=false" >> "$GITHUB_OUTPUT"
fi
deploy:
name: Deploy
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
needs:
- test
- check-permissions
if: |
github.ref == 'refs/heads/main' ||
needs.check-permissions.outputs.write_access == 'true'
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 23
- name: Install dependencies
run: pnpm install --production --ignore-scripts
- name: Build OKLCH
run: node --run build
- name: Deploy OKLCH
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy dist/ --project-name=oklch
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
- name: Re-build LCH
if: github.ref == 'refs/heads/main'
run: node --run clean && node --run build:lch
- name: Deploy LCH
if: github.ref == 'refs/heads/main'
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy dist/ --project-name=lch