|
13 | 13 | permissions:
|
14 | 14 | contents: read
|
15 | 15 | deployments: write
|
| 16 | + issues: write |
| 17 | + pull-requests: write |
| 18 | + checks: write |
| 19 | + statuses: write |
16 | 20 | outputs:
|
17 |
| - deployment_url: ${{ steps.cloudflare.outputs.url }} |
| 21 | + deployment_url: ${{ steps.deploy.outputs.url }} |
18 | 22 | steps:
|
19 | 23 | - name: Checkout
|
20 | 24 | uses: actions/checkout@v4
|
@@ -52,27 +56,55 @@ jobs:
|
52 | 56 | SENTRY_ORG: ${{ vars.SENTRY_ORG }}
|
53 | 57 | SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
|
54 | 58 | SENTRY_DSN: ${{ vars.SENTRY_DSN }}
|
55 |
| - - id: cloudflare |
56 |
| - name: Publish to Cloudflare Pages |
57 |
| - uses: cloudflare/pages-action@v1 |
| 59 | + - id: deploy |
| 60 | + name: Publish to Cloudflare Pages (Preview) |
| 61 | + uses: cloudflare/wrangler-action@v3 |
58 | 62 | with:
|
59 | 63 | apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
60 | 64 | accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
61 |
| - projectName: ${{ vars.CLOUDFLARE_PROJECT_NAME }} |
62 |
| - directory: ./packages/gitbook/.vercel/output/static |
63 |
| - gitHubToken: ${{ secrets.GITHUB_TOKEN }} |
64 | 65 | workingDirectory: ./
|
| 66 | + wranglerVersion: '3.82.0' |
| 67 | + command: pages deploy ./packages/gitbook/.vercel/output/static --project-name=${{ vars.CLOUDFLARE_PROJECT_NAME }} --branch=${{ github.ref == 'refs/heads/main' && 'main' || format('pr{0}', github.event.pull_request.number) }} |
65 | 68 | - name: Outputs
|
66 | 69 | run: |
|
67 |
| - echo "ID: ${{ steps.cloudflare.outputs.id }}" |
68 |
| - echo "URL: ${{ steps.cloudflare.outputs.url }}" |
69 |
| - echo "Environment: ${{ steps.cloudflare.outputs.environment }}" |
70 |
| - echo "Alias: ${{ steps.cloudflare.outputs.alias }}" |
| 70 | + echo "URL: ${{ steps.deploy.outputs.url }}" |
| 71 | + echo "Alias URL: ${{ steps.deploy.outputs.deployment-alias-url }}" |
71 | 72 | - name: Archive build output
|
72 | 73 | uses: actions/upload-artifact@v4
|
73 | 74 | with:
|
74 | 75 | name: build-output
|
75 | 76 | path: .vercel/
|
| 77 | + # Until https://github.com/cloudflare/wrangler-action/issues/301 is done |
| 78 | + - name: Update Deployment Status to Success |
| 79 | + env: |
| 80 | + DEPLOYMENT_URL: ${{ steps.deploy.outputs.url }} |
| 81 | + run: | |
| 82 | + curl -X POST \ |
| 83 | + -H "Authorization: token ${{ secrets.GH_PERSONAL_TOKEN }}" \ |
| 84 | + -H "Accept: application/vnd.github.v3+json" \ |
| 85 | + -d '{"state": "success", "target_url": "${{ steps.deploy.outputs.url }}", "description": "GitBook Preview URL", "context": "default"}' \ |
| 86 | + https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} |
| 87 | +
|
| 88 | + - name: Find GitHub Comment |
| 89 | + uses: peter-evans/find-comment@v3 |
| 90 | + id: fc |
| 91 | + if: 1 && !startsWith(github.ref, 'refs/heads/main') |
| 92 | + with: |
| 93 | + issue-number: ${{ github.event.pull_request.number }} |
| 94 | + comment-author: 'github-actions[bot]' |
| 95 | + body-includes: GitBook Preview |
| 96 | + |
| 97 | + - name: Create or update GitHub comment |
| 98 | + uses: peter-evans/create-or-update-comment@v4 |
| 99 | + if: 1 && !startsWith(github.ref, 'refs/heads/main') |
| 100 | + with: |
| 101 | + comment-id: ${{ steps.fc.outputs.comment-id }} |
| 102 | + issue-number: ${{ github.event.pull_request.number }} |
| 103 | + body: | |
| 104 | + **GitBook Preview** |
| 105 | + Latest commit: [${{ steps.deploy.outputs.url }}](${{ steps.deploy.outputs.url }}) |
| 106 | + PR: [${{ steps.deploy.outputs.alias }}](${{ steps.deploy.outputs.alias }}) |
| 107 | + edit-mode: replace |
76 | 108 | visual-testing:
|
77 | 109 | runs-on: ubuntu-latest
|
78 | 110 | name: Visual Testing
|
|
0 commit comments