Skip to content

Commit 1a27185

Browse files
authored
Merge pull request #74 from clerk/nick/preview-links
Preview Links
2 parents e87310a + 2092ec5 commit 1a27185

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

.github/workflows/preview.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: PR Preview Links
2+
permissions:
3+
contents: read
4+
pull-requests: write
5+
6+
on:
7+
pull_request:
8+
types: [opened]
9+
10+
jobs:
11+
preview-comment:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Encode branch name
15+
id: encode-branch
16+
run: |
17+
encoded=$(printf '%s' "${{ github.head_ref }}" | jq -sRr @uri)
18+
echo "branch=$encoded" >> $GITHUB_OUTPUT
19+
20+
- name: Find existing comment
21+
uses: peter-evans/find-comment@v3
22+
id: find-comment
23+
with:
24+
issue-number: ${{ github.event.pull_request.number }}
25+
comment-author: "github-actions[bot]"
26+
body-includes: "<!-- preview-links -->"
27+
28+
- name: Create preview comment
29+
if: steps.find-comment.outputs.comment-id == ''
30+
uses: peter-evans/create-or-update-comment@v4
31+
with:
32+
issue-number: ${{ github.event.pull_request.number }}
33+
body: |
34+
<!-- preview-links -->
35+
## Preview Links
36+
37+
- [Backend API](https://clerk.com/docs/reference/${{ steps.encode-branch.outputs.branch }}/backend-api)
38+
- [Frontend API](https://clerk.com/docs/reference/${{ steps.encode-branch.outputs.branch }}/frontend-api)

0 commit comments

Comments
 (0)