File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change 1- name : ' Preview Deployment'
1+ name : ' Deployment to Cloudflare Pages '
22on :
33 pull_request_target :
44 types : [opened, synchronize, reopened]
55 branches :
66 - master
7+ push :
8+ branches :
9+ - master
710
811jobs :
912 # Job 1: Build the code (no secrets here)
@@ -60,16 +63,29 @@ jobs:
6063 run : |
6164 calculatedSha=$(echo ${{ github.event.pull_request.head.sha }} | head -c 8)
6265 echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
63-
66+
67+ - name : Set alias branch name for Cloudflare (if a push)
68+ id : branch_push
69+ if : github.event_name == 'push'
70+ run : |
71+ echo "BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
72+
73+ - name : Set alias branch name for Cloudflare (if a pull_request)
74+ id : branch_pull
75+ if : github.event_name == 'pull_request_target' || github.event_name == 'pull_request'
76+ run : |
77+ echo "BRANCH=PR${{ github.event.pull_request.number }}" >> $GITHUB_ENV
78+
6479 - name : Deploy to Cloudflare
6580 id : deploy
6681 uses : cloudflare/wrangler-action@v3
6782 with :
6883 apiToken : ${{ secrets.CLOUDFLARE_API_TOKEN }}
6984 accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
70- command : pages deploy dist --project-name=${{ vars.CLOUDFLARE_PROJECT_NAME }} --branch=PR ${{ github.event.pull_request.number }} --commit-dirty=true
85+ command : pages deploy dist --project-name=${{ vars.CLOUDFLARE_PROJECT_NAME }} --branch=${{ env.BRANCH }} --commit-dirty=true
7186
7287 - name : Add deployment comment
88+ if : github.event_name == 'pull_request_target' || github.event_name == 'pull_request'
7389 uses : thollander/actions-comment-pull-request@v3
7490 with :
7591 message : |
You can’t perform that action at this time.
0 commit comments