Skip to content

Commit a918130

Browse files
authored
chore: fix preview release to use correct target (#107)
1 parent 8bd087b commit a918130

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

.github/workflows/preview-release.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,25 @@ on:
1515
description: 'Target branch for supabase-js tests'
1616
type: string
1717
default: 'master'
18-
19-
# Push to master - only when source code changes
18+
19+
# Push to main - only when source code changes
2020
push:
2121
branches:
22-
- master
22+
- main
2323
paths:
2424
- 'src/**'
2525
- 'package.json'
2626
- 'package-lock.json'
2727
- 'tsconfig.json'
28-
28+
2929
# PR triggers - only when labeled
30-
pull_request:
30+
# Using pull_request_target to access secrets when PRs come from forks
31+
pull_request_target:
3132
types: [labeled, synchronize]
3233

3334
jobs:
3435
preview:
35-
# Run only for PRs with 'trigger: preview' label or pushes to master
36+
# Run only for PRs with 'trigger: preview' label or pushes to main
3637
if: >
3738
github.repository == 'supabase/functions-js' &&
3839
(
@@ -47,6 +48,9 @@ jobs:
4748
steps:
4849
- name: Checkout code
4950
uses: actions/checkout@v4
51+
with:
52+
# For pull_request_target, we need to explicitly checkout the PR's head
53+
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}
5054

5155
- name: Setup Node.js
5256
uses: actions/setup-node@v4
@@ -106,10 +110,10 @@ jobs:
106110
script: |
107111
const prNumber = context.issue.number || 'push';
108112
const triggeringRepo = context.repo.repo;
109-
// Use input target_branch if workflow_dispatch, otherwise default to master
113+
// Use input target_branch if workflow_dispatch, otherwise default to main
110114
const targetBranch = context.eventName === 'workflow_dispatch' && context.payload.inputs?.target_branch
111115
? context.payload.inputs.target_branch
112-
: 'master';
116+
: 'main';
113117
114118
try {
115119
const response = await github.rest.actions.createWorkflowDispatch({
@@ -153,11 +157,11 @@ jobs:
153157
body: |
154158
<!-- functions-js-preview-status -->
155159
🚀 **Preview release created!**
156-
160+
157161
supabase-js CI tests have been automatically triggered on feature branch to verify compatibility.
158-
162+
159163
**Preview package:** `${{ needs.preview.outputs.preview-url }}`
160-
164+
161165
Results will be posted here once testing is complete.
162-
166+
163167
edit-mode: replace

0 commit comments

Comments
 (0)