File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ name: 1 - Check and Build Web Page PR
33
44on :
55 pull_request :
6- branches : [ "main" ]
6+ branches : ["main"]
77
88jobs :
99 linter :
4747 uses : actions/upload-artifact@v4
4848 with :
4949 name : pr-metadata
50- path : pr-number.txt
50+ path : pr-number.txt
Original file line number Diff line number Diff line change 2424 uses : actions/upload-artifact@v4
2525 with :
2626 name : pr-metadata
27- path : pr-number.txt
27+ path : pr-number.txt
Original file line number Diff line number Diff line change 2929 name : pr-metadata
3030 run-id : ${{ github.event.workflow_run.id }}
3131 github-token : ${{ secrets.GITHUB_TOKEN }}
32-
32+
3333 - name : Set PR Number Context
3434 run : |
3535 PR_NUMBER=$(cat pr-number.txt)
@@ -45,27 +45,27 @@ jobs:
4545 PR_NUMBER : ${{ env.PR_NUMBER }}
4646 run : |
4747 echo "Cleaning up deployments for PR #$PR_NUMBER..."
48-
48+
4949 # 1. Install the Cloudflare Wrangler CLI
5050 npm install -g wrangler
51-
51+
5252 # 2. Fetch all project deployments as a JSON payload
5353 wrangler pages deployment list --project-name $PROJECT_NAME --json > deployments.json
54-
54+
5555 # 3. Use 'jq' to filter the JSON for deployments matching this PR's branch
5656 # (In our previous step, we named the branch 'pr-123')
5757 TARGET_IDS=$(jq -r ".[] | select(.Branch == \"pr-$PR_NUMBER\") | .Id" deployments.json)
58-
58+
5959 # Check if any deployments were actually found
6060 if [ -z "$TARGET_IDS" ]; then
6161 echo "No preview deployments found for pr-$PR_NUMBER."
6262 exit 0
6363 fi
64-
64+
6565 # 4. Loop through the matching IDs and force-delete them
6666 for ID in $TARGET_IDS; do
6767 echo "Deleting deployment ID: $ID..."
6868 wrangler pages deployment delete $ID --project-name $PROJECT_NAME --force
6969 done
70-
70+
7171 echo "🎉 Cleanup complete!"
Original file line number Diff line number Diff line change 3737 name : pr-metadata
3838 run-id : ${{ github.event.workflow_run.id }}
3939 github-token : ${{ secrets.GITHUB_TOKEN }}
40-
40+
4141 - name : Set PR Number Context
4242 run : |
4343 PR_NUMBER=$(cat pr-number.txt)
4949 uses : cloudflare/wrangler-action@v3
5050 with :
5151 apiToken : ${{ secrets.CLOUDFLARE_API_TOKEN }}
52- accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
52+ accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
5353 command : |
5454 pages deploy site/ --project-name=openshift-examples --branch pr-${{ env.PR_NUMBER }}
5555 # Optional: Enable this if you want to have GitHub Deployments triggered
6363 run : |
6464 gh pr comment ${{ env.PR_NUMBER }} \
6565 --repo ${{ github.repository }} \
66- --body "🚀 **Preview Deployment Success!** View your live changes here: $DEPLOYMENT_URL\n\n$CMD_OUTPUT"
66+ --body "🚀 **Preview Deployment Success!** View your live changes here: $DEPLOYMENT_URL\n\n$CMD_OUTPUT"
Original file line number Diff line number Diff line change 3939 cloudflare-project-name : ${{ vars.CLOUDFLARE_PROJECT_NAME }}
4040 directory : site
4141 github-token : ${{ secrets.GITHUB_TOKEN }}
42- github-environment : Cloudflare Pages
42+ github-environment : Cloudflare Pages
You can’t perform that action at this time.
0 commit comments