From 738f3423d7f8d7534b88c9445ab8da9f60c381bc Mon Sep 17 00:00:00 2001 From: Nikos Douvlis Date: Fri, 10 Nov 2023 15:16:05 +0200 Subject: [PATCH] chore(repo): Introduce retheme-preview action --- .github/workflows/preview.retheme.yml | 85 +++++++++++++++++++++++++++ .github/workflows/preview.yml | 2 +- 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/preview.retheme.yml diff --git a/.github/workflows/preview.retheme.yml b/.github/workflows/preview.retheme.yml new file mode 100644 index 00000000000..e0114e6b6b4 --- /dev/null +++ b/.github/workflows/preview.retheme.yml @@ -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 diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 79ec8ba99bc..d2fc29d44e9 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -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: |