|
80 | 80 |
|
81 | 81 | ${{ steps.deploy.outputs.command-output }} |
82 | 82 |
|
| 83 | + deploy-guide: |
| 84 | + runs-on: ubuntu-latest |
| 85 | + name: Deploy Guide Worker |
| 86 | + if: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false) && github.actor != 'dependabot[bot]' }} |
| 87 | + permissions: |
| 88 | + contents: read |
| 89 | + deployments: write |
| 90 | + pull-requests: write |
| 91 | + steps: |
| 92 | + - uses: actions/checkout@v6.0.2 |
| 93 | + - name: Setup Node.js environment |
| 94 | + uses: actions/setup-node@v6.3.0 |
| 95 | + with: |
| 96 | + node-version-file: ".node-version" |
| 97 | + cache: "yarn" |
| 98 | + - name: Enable Corepack |
| 99 | + run: corepack enable |
| 100 | + - name: Install dependencies |
| 101 | + run: yarn install |
| 102 | + - name: Build guide |
| 103 | + run: yarn build:guide |
| 104 | + - name: Set guide deployment command |
| 105 | + shell: bash |
| 106 | + run: | |
| 107 | + RAW_BRANCH="${{ github.head_ref || github.ref_name }}" |
| 108 | + SAFE_BRANCH=$(echo "$RAW_BRANCH" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9-]+/-/g; s/^-+//; s/-+$//; s/-+/-/g') |
| 109 | + SAFE_BRANCH="${SAFE_BRANCH:0:28}" |
| 110 | +
|
| 111 | + if [[ "${{ github.event_name }}" == "push" && "$RAW_BRANCH" == "master" ]] || [[ "${{ inputs.environment }}" == "production" ]]; then |
| 112 | + echo "GUIDE_DEPLOY_COMMAND=deploy" >> "$GITHUB_ENV" |
| 113 | + else |
| 114 | + echo "GUIDE_DEPLOY_COMMAND=versions upload --preview-alias=$SAFE_BRANCH" >> "$GITHUB_ENV" |
| 115 | + fi |
| 116 | + - name: Deploy guide |
| 117 | + id: deploy-guide |
| 118 | + uses: cloudflare/wrangler-action@v3 |
| 119 | + with: |
| 120 | + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
| 121 | + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
| 122 | + workingDirectory: apps/guide |
| 123 | + command: ${{ env.GUIDE_DEPLOY_COMMAND }} |
| 124 | + wranglerVersion: 4.85.0 |
| 125 | + env: |
| 126 | + FORCE_COLOR: 0 |
| 127 | + - name: Comment PR with guide deployment link |
| 128 | + if: ${{ github.event_name == 'pull_request' }} |
| 129 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 130 | + with: |
| 131 | + recreate: true |
| 132 | + header: guide-deployment |
| 133 | + message: | |
| 134 | + ## Guide Cloudflare deployment |
| 135 | +
|
| 136 | + ${{ steps.deploy-guide.outputs.command-output }} |
| 137 | +
|
83 | 138 | e2e: |
84 | 139 | runs-on: ubuntu-latest |
85 | 140 | name: E2E Tests |
|
0 commit comments