Skip to content

Commit 42e8550

Browse files
committed
DEPLOYMENT: Updating deployment to build on push
1 parent 2633081 commit 42e8550

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

.github/workflows/deploy-preview.yml renamed to .github/workflows/deploy.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
name: 'Preview Deployment'
1+
name: 'Deployment to Cloudflare Pages'
22
on:
33
pull_request_target:
44
types: [opened, synchronize, reopened]
55
branches:
66
- master
7+
push:
8+
branches:
9+
- master
710

811
jobs:
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: |

0 commit comments

Comments
 (0)