Skip to content

Deploy Cloudflare Pages #2731

Deploy Cloudflare Pages

Deploy Cloudflare Pages #2731

name: Deploy Cloudflare Pages
on:
workflow_run:
workflows: ['CI']
types: [completed]
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
GITHUB_SHA: ${{ github.sha }}
TURBO_TOKEN: ${{ secrets.TURBOREPO_REMOTE_CACHE_AUTH_SECRET }}
TURBO_API: 'https://turbo-cache.adishwar-rishi.com'
TURBO_TEAM: 'team_arishi_monorepo'
TURBO_REMOTE_CACHE_SIGNATURE_KEY: ${{ secrets.TURBOREPO_REMOTE_CACHE_SIGNATURE_KEY }}
jobs:
check:
name: Build and deploy CF Pages
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success' || github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- run: pnpm install
- run: pnpm build
- name: Deploy arishi-website-webapp
id: deploy-arishi-website-webapp
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
command: deploy --minify
workingDirectory: 'webapps/arishi-website'
packageManager: 'pnpm'
- name: Comment with deploy link
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const apps = [
{ name: 'arishi-website-webapp', url: process.env.ARISHI_WEBSITE_WEBAPP_DEPLOYMENT_URL },
// Add more apps here
];
const commitHash = context.payload.pull_request.head.sha;
const status = '✅ Deploy successful!';
let tableHeader = '| App Name | Last Commit | Preview URL | Status |';
let tableDivider = '| --------- | ----------- | ----------- | ------ |';
let tableRows = apps.map(app => `| ${app.name} | \`${commitHash.substring(0, 7)}\` | ${app.url} | ${status} |`).join('\n');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `
# 🌩 Deploying with Cloudflare Pages
${tableHeader}
${tableDivider}
${tableRows}
`
});
env:
ARISHI_WEBSITE_WEBAPP_DEPLOYMENT_URL: ${{ steps.deploy-arishi-website-webapp.outputs.deployment-url }}