Skip to content

Commit 04fb0e7

Browse files
ok
1 parent 6c25d46 commit 04fb0e7

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

.github/workflows/pr-preview.yaml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,37 @@ name: PR Preview
33
on:
44
pull_request_target:
55
types: [labeled]
6+
workflow_dispatch:
7+
inputs:
8+
pr_number:
9+
description: "PR number to build preview for"
10+
required: true
11+
type: string
12+
ref:
13+
description: "Git ref to checkout (commit SHA or branch)"
14+
required: true
15+
type: string
616

717
permissions:
818
contents: read
919
pull-requests: write
1020
id-token: write
1121

1222
concurrency:
13-
group: pr-preview-${{ github.event.pull_request.number }}
23+
group: pr-preview-${{ github.event.pull_request.number || inputs.pr_number }}
1424
cancel-in-progress: true
1525

1626
jobs:
1727
publish-preview:
1828
name: Publish Preview
1929
runs-on: ubuntu-latest
20-
if: github.event.label.name == 'preview'
30+
if: github.event.label.name == 'preview' || github.event_name == 'workflow_dispatch'
2131
timeout-minutes: 30
2232
steps:
2333
- name: Checkout PR Code
2434
uses: actions/checkout@v4
2535
with:
26-
ref: ${{ github.event.pull_request.head.sha }}
36+
ref: ${{ github.event.pull_request.head.sha || inputs.ref }}
2737
fetch-depth: 0
2838

2939
- name: Setup Bun
@@ -39,8 +49,9 @@ jobs:
3949
- name: Generate Preview Version
4050
id: version
4151
run: |
42-
PR_NUMBER=${{ github.event.pull_request.number }}
43-
COMMIT_SHA=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c1-7)
52+
PR_NUMBER=${{ github.event.pull_request.number || inputs.pr_number }}
53+
REF="${{ github.event.pull_request.head.sha || inputs.ref }}"
54+
COMMIT_SHA=$(echo "$REF" | cut -c1-7)
4455
BASE_VERSION=$(jq -r '.version' apps/cli/package.json | sed -E 's/^([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
4556
PREVIEW_VERSION="${BASE_VERSION}-pr${PR_NUMBER}.${COMMIT_SHA}"
4657
NPM_TAG="pr${PR_NUMBER}"
@@ -119,15 +130,15 @@ jobs:
119130
uses: peter-evans/find-comment@v3
120131
id: find-comment
121132
with:
122-
issue-number: ${{ github.event.pull_request.number }}
133+
issue-number: ${{ github.event.pull_request.number || inputs.pr_number }}
123134
comment-author: "github-actions[bot]"
124135
body-includes: "PR Preview Release"
125136

126137
- name: Create or update PR comment
127138
uses: peter-evans/create-or-update-comment@v4
128139
with:
129140
comment-id: ${{ steps.find-comment.outputs.comment-id }}
130-
issue-number: ${{ github.event.pull_request.number }}
141+
issue-number: ${{ github.event.pull_request.number || inputs.pr_number }}
131142
edit-mode: replace
132143
body: |
133144
## PR Preview Release

0 commit comments

Comments
 (0)