Skip to content

Commit 2ae40b8

Browse files
bradlckylemac
andauthored
[DO NOT MERGE] Update GitHub workflows for docs redesign (#918)
Co-authored-by: Kyle MacDonald <[email protected]>
1 parent da897a6 commit 2ae40b8

File tree

3 files changed

+41
-190
lines changed

3 files changed

+41
-190
lines changed

.github/workflows/preview.yml

Lines changed: 20 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,160 +1,35 @@
1-
name: Deploy Preview
1+
name: Pull Request Preview
22

33
env:
4-
COMMENT_HEADER: clerk-docs-preview
4+
API_BASE_URL: https://clerk.com
5+
PREVIEW_BASE_URL: https://clerk.com
56

67
on:
7-
pull_request_target:
8-
types: [labeled, synchronize]
8+
pull_request:
9+
types: [labeled, unlabeled]
910

1011
jobs:
11-
# When a PR is labeled with the `deploy-preview` label, we manually trigger a preview deployment of the site and assign it a stable URL.
12-
# A comment is kept up-to-date on the PR as the deployment progresses.
13-
#
14-
# Forks are handled by using the gh CLI to checkout the forked branch, and then we push up a branch to the origin.
15-
# This should be safe as it requires someone with triage permissions on the repository to apply the label.
16-
deploy:
17-
env:
18-
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
19-
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
20-
permissions:
21-
contents: write
22-
pull-requests: write
23-
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'deploy-preview' }}
24-
runs-on: ubuntu-latest
25-
26-
steps:
27-
- name: Get date
28-
run: |
29-
echo "DATE=$(date -u +"%b %d, %Y %I:%M %p")" >> $GITHUB_ENV
30-
31-
- uses: actions/[email protected]
32-
33-
- name: Checkout fork
34-
env:
35-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36-
id: checkout-fork
37-
if: ${{ github.event.pull_request.head.repo.fork == true }}
38-
run: |
39-
gh pr checkout ${{ github.event.pull_request.number }}
40-
git_branch=$(git rev-parse --abbrev-ref HEAD)
41-
git push origin $git_branch
42-
echo "branch=$git_branch" >> $GITHUB_OUTPUT
43-
44-
- name: Checkout application
45-
uses: actions/[email protected]
46-
with:
47-
repository: clerk/clerk-marketing
48-
token: ${{ secrets.CLERK_GH_TOKEN }}
49-
path: app
50-
ref: production
51-
52-
- run: npm install --global vercel@latest
53-
54-
- name: Pull Vercel environment information
55-
run: |
56-
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
57-
58-
- name: Deploy to Vercel
59-
id: vercel-deploy
60-
env:
61-
DOCS_BRANCH: ${{ steps.checkout-fork.outputs.branch || github.event.pull_request.head.ref }}
62-
run: |
63-
cd app
64-
git checkout -b preview/$DOCS_BRANCH
65-
vercel deploy --token=${{ secrets.VERCEL_TOKEN }} --build-env DOCS_BRANCH=$DOCS_BRANCH --env DOCS_BRANCH=$DOCS_BRANCH --no-wait > deployment_url.txt
66-
echo "url=$(cat deployment_url.txt)" >> $GITHUB_OUTPUT
67-
68-
- name: Create preview comment - baking
69-
uses: marocchino/[email protected]
70-
with:
71-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72-
number: ${{ github.event.pull_request.number }}
73-
header: ${{ env.COMMENT_HEADER}}
74-
message: |
75-
Hey @${{ github.event.sender.login }}, your docs preview is currently baking and should be available shortly.
76-
77-
| Status | Preview | Updated (UTC) |
78-
| :-- | :-- | :-- |
79-
| :cook: _Baking..._ | [Inspect](${{ steps.vercel-deploy.outputs.url }}) | ${{ env.DATE }} |
80-
81-
- name: Get date
82-
run: |
83-
echo "DATE=$(date -u +"%b %d, %Y %I:%M %p")" >> $GITHUB_ENV
84-
85-
- name: Wait for deployment
86-
id: vercel-wait-for-deploy
87-
run: |
88-
vercel inspect --token=${{ secrets.VERCEL_TOKEN }} --wait ${{ steps.vercel-deploy.outputs.url }} --timeout 10m --scope clerk-production
89-
vercel alias set ${{ steps.vercel-deploy.outputs.url }} docs-preview-${{ github.event.pull_request.number }}.clerkpreview.com --token=${{ secrets.VERCEL_TOKEN }} --scope clerk-production
90-
echo "stable_url=https://docs-preview-${{ github.event.pull_request.number }}.clerkpreview.com" >> $GITHUB_OUTPUT
91-
92-
- name: Create preview comment - deployed
93-
uses: marocchino/[email protected]
94-
with:
95-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96-
number: ${{ github.event.pull_request.number }}
97-
header: ${{ env.COMMENT_HEADER }}
98-
message: |
99-
Hey @${{ github.event.sender.login }}, your docs preview is available.
100-
101-
| Status | Preview | Updated (UTC) |
102-
| :-- | :-- | :-- |
103-
| :cookie: Deployed | [Visit preview](${{ steps.vercel-wait-for-deploy.outputs.stable_url }}/docs) | ${{ env.DATE }} |
104-
105-
<!-- deployed:true -->
106-
107-
# On PR sync, trigger a revalidate of the existing deploy preview. This is much faster than a full re-deploy.
108-
revalidate:
109-
if: ${{ github.event.action == 'synchronize' }}
12+
pr_preview:
13+
if: ${{ github.event.label.name == 'deploy-preview' }}
11014
runs-on: ubuntu-latest
11115
permissions:
112-
contents: read
11316
pull-requests: write
114-
env:
115-
CLERK_COM_BASE_URL: https://docs-preview-${{ github.event.pull_request.number }}.clerkpreview.com
11617
steps:
117-
- name: Find comment
118-
uses: peter-evans/[email protected]
119-
id: find-comment
120-
with:
121-
issue-number: ${{ github.event.pull_request.number }}
122-
body-includes: deployed:true
123-
124-
- name: Update fork
125-
env:
126-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127-
id: checkout-fork
128-
if: ${{ github.event.pull_request.head.repo.fork == true && steps.find-comment.outputs.comment-id != 0}}
129-
run: |
130-
gh pr checkout ${{ github.event.pull_request.number }}
131-
git_branch=$(git rev-parse --abbrev-ref HEAD)
132-
git push origin $git_branch
133-
134-
- name: Get date
18+
- name: Revalidate PR preview
13519
run: |
136-
echo "DATE=$(date -u +"%b %d, %Y %I:%M %p")" >> $GITHUB_ENV
137-
138-
- name: Trigger revalidate
139-
if: ${{ steps.find-comment.outputs.comment-id != 0 }}
140-
run: |
141-
curl -X POST ${{ env.CLERK_COM_BASE_URL }}/api/revalidate-docs \
20+
curl -X POST ${{ env.API_BASE_URL }}/docs/revalidate \
14221
-H "Content-Type: application/json" \
14322
-H "Authorization: Bearer ${{ secrets.REVALIDATE_DOCS_SECRET }}" \
144-
-d "{\"paths\": \"*\"}"
23+
-d "{\"tags\": [\"docs:pr:${{ github.event.pull_request.number }}\"]}"
14524
146-
- name: Create preview comment - updated
147-
if: ${{ steps.find-comment.outputs.comment-id != 0 }}
148-
uses: marocchino/[email protected]
25+
- name: Share PR preview URL
26+
if: ${{ github.event.action == 'labeled' }}
27+
uses: actions/github-script@v7
14928
with:
150-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
151-
number: ${{ github.event.pull_request.number }}
152-
header: ${{ env.COMMENT_HEADER }}
153-
message: |
154-
Hey @${{ github.event.sender.login }}, your docs preview is available.
155-
156-
| Status | Preview | Updated (UTC) |
157-
| :-- | :-- | :-- |
158-
| :cookie: Updated | [Visit preview](${{ env.CLERK_COM_BASE_URL }}/docs) | ${{ env.DATE }} |
159-
160-
<!-- deployed:true -->
29+
script: |
30+
github.rest.issues.createComment({
31+
issue_number: context.issue.number,
32+
owner: context.repo.owner,
33+
repo: context.repo.repo,
34+
body: 'Hey, here’s your docs preview: ' + process.env.PREVIEW_BASE_URL + '/docs/pr/' + context.issue.number,
35+
})

.github/workflows/redeploy.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Redeploy
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- core-1
9+
paths:
10+
- 'docs/**'
11+
12+
jobs:
13+
redeploy:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Trigger redeploy
17+
run: |
18+
curl -X POST ${{ secrets.WEBSITE_DEPLOY_HOOK }}
19+
- name: Trigger search reindex
20+
run: |
21+
curl -X POST ${{ secrets.SEARCH_INDEX_DEPLOY_HOOK }}

.github/workflows/revalidate.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)