Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 11 additions & 36 deletions .github/workflows/deploy-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ on:
push:
branches: [main]

permissions:
contents: read

concurrency:
group: deploy-examples
cancel-in-progress: false

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
environment:
name: production
url: ${{ steps.deploy.outputs.url }}
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -65,45 +72,13 @@ jobs:
</html>
EOF

- name: Create GitHub deployment
id: create-deployment
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { data } = await github.rest.repos.createDeployment({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.sha,
environment: 'production',
auto_merge: false,
required_contexts: [],
description: 'Cloudflare Workers',
});
return String(data.id);

- name: Deploy to Cloudflare
id: deploy
run: |
OUTPUT=$(pnpm dlx wrangler deploy --assets=./pages 2>&1)
OUTPUT=$(pnpm dlx wrangler@4.145.0 deploy --assets=./pages 2>&1)
echo "$OUTPUT"
URL=$(echo "$OUTPUT" | grep -oE 'https://[a-zA-Z0-9._-]+\.workers\.dev' | tail -1)
echo "url=$URL" >> $GITHUB_OUTPUT
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

- name: Update deployment status
if: always()
uses: actions/github-script@v7
with:
script: |
await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: ${{ steps.create-deployment.outputs.result }},
state: '${{ steps.deploy.outcome }}' === 'success' ? 'success' : 'failure',
environment_url: '${{ steps.deploy.outputs.url }}',
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
auto_inactive: true,
});
Loading