Skip to content

Commit

Permalink
chore(repo): Introduce retheme-preview action
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosdouvlis committed Nov 10, 2023
1 parent 8b4c67a commit 738f342
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 1 deletion.
85 changes: 85 additions & 0 deletions .github/workflows/preview.retheme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Deploy Retheme Preview
run-name: Deploy Retheme Preview by ${{ github.actor }}

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_CLERK_PROD_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_JS_RETHEME_PROJECT_ID }}

on:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.actor }}
cancel-in-progress: true

jobs:
preview:
runs-on: ${{ vars.RUNNER_NORMAL }}
timeout-minutes: ${{ fromJSON(vars.TIMEOUT_MINUTES_NORMAL) }}
permissions:
contents: write
pull-requests: write
steps:
- name: Limit action to Clerk members
uses: actions/github-script@v6
with:
result-encoding: string
retries: 3
retry-exempt-status-codes: 400,401
github-token: ${{ secrets.CLERK_COOKIE_PAT }}
script: |
const isMember = await github.rest.orgs.checkMembershipForUser({
org: 'clerk',
username: context.actor
});
if (!isMember) {
core.setFailed(`@${actor} is not a member of the Clerk organization`);
}
- name: Checkout repo
uses: actions/checkout@v4

- name: Setup
id: config
uses: ./.github/actions/init
with:
turbo-signature: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
turbo-team: ${{ vars.TURBO_TEAM }}
turbo-token: ${{ secrets.TURBO_TOKEN }}
registry-url: "https://registry.npmjs.org"

- name: Build packages
run: |
npx turbo build $TURBO_ARGS --filter='!@clerk/clerk-js' --filter='!@clerk/localizations' --filter='!@clerk/types'
CLERK_RETHEME=1 npx turbo build $TURBO_ARGS --filter='@clerk/clerk-js' --filter='@clerk/localizations' --filter='@clerk/types'
- name: Install site in isolation
run: node scripts/install-site-in-isolation.mjs playground/nextjs

- name: Install Vercel CLI
run: npm install --global vercel@latest

- name: Pull Vercel environment information
run: |
cd $FULL_TMP_FOLDER
vercel pull --yes --environment=prod --token=${{ secrets.VERCEL_CLERK_COOKIE_TOKEN }}
- name: Copy clerk-js/dist into public/clerk-js of test site
run: |
cp -r $GITHUB_WORKSPACE/packages/clerk-js/dist $FULL_TMP_FOLDER/public/clerk-js
- name: Build with Vercel
run: |
cd $FULL_TMP_FOLDER
vercel build --yes --prod
env:
NEXT_PUBLIC_CLERK_JS: /clerk-js/clerk.browser.js

- name: Deploy to Vercel (prebuilt)
id: vercel-deploy
run: |
cd $FULL_TMP_FOLDER
vercel deploy --prebuilt --token=${{ secrets.VERCEL_CLERK_COOKIE_TOKEN }} --no-wait --prod > deployment_url.txt
echo "url=$(cat deployment_url.txt)" >> $GITHUB_OUTPUT
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
registry-url: "https://registry.npmjs.org"

- name: Build packages
run: npx turbo build $TURBO_ARGS --force
run: npx turbo build $TURBO_ARGS

- name: Get date
run: |
Expand Down

0 comments on commit 738f342

Please sign in to comment.