chore(docs): use vercel ci again because GH secret problem on forks (#8142)

# Fallback to Vercel CI

Since we cannot share the vercel_token on forks we cannot deploy by
vercel CLI.
This PR reverts to the last working state by using vercel CI.

I will look into a fix with an npm script or a turbo config to ignore
builds on folder changes.
This commit is contained in:
Florian Forster 2024-06-14 16:50:58 +02:00 committed by GitHub
parent 21ffe4f693
commit cf72bd6192
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 1 additions and 108 deletions

View File

@ -20,13 +20,6 @@ permissions:
pull-requests: write
jobs:
docs:
uses: ./.github/workflows/docsusaurus.yml
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
core:
uses: ./.github/workflows/core.yml
with:

View File

@ -1,100 +0,0 @@
name: Docs
on:
workflow_call:
secrets:
VERCEL_TOKEN:
description: 'Vercel API Token'
required: true
VERCEL_ORG_ID:
description: 'Vercel Org/Team ID'
required: true
VERCEL_PROJECT_ID:
description: 'Vercel Project ID'
required: true
jobs:
Deploy:
runs-on: ubuntu-latest
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
src:
- 'docs/**'
- 'proto/**'
- '.github/workflows/docsusaurus.yml'
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
cache-dependency-path: docs/yarn.lock
- name: Install Vercel CLI
run: yarn global add vercel
- name: Install Dependencies
if: steps.filter.outputs.src == 'true'
run: yarn install --frozen-lockfile
working-directory: ./docs
- uses: actions/cache@v4
if: steps.filter.outputs.src == 'true'
with:
path: |
${{ github.workspace }}/docs/.docusaurus
${{ github.workspace }}/docs/node_modules/.cache
key: |
${{ runner.os }}-docusaurus-${{ hashFiles('**/package-lock.json', '**/npm-shrinkwrap.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-docusaurus-${{ hashFiles('**/package-lock.json', '**/npm-shrinkwrap.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}
${{ runner.os }}-docusaurus-${{ hashFiles('docs/yarn.lock') }}
- name: Prepare Preview Environment
if: ${{ github.ref != 'refs/heads/main' && steps.filter.outputs.src == 'true' }}
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Perpare Production Environment
if: ${{ github.ref == 'refs/heads/main' && steps.filter.outputs.src == 'true' }}
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Preview
if: ${{ github.ref != 'refs/heads/main' && steps.filter.outputs.src == 'true' }}
env:
NODE_OPTIONS: "--max_old_space_size=8192"
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Production
if: ${{ github.ref == 'refs/heads/main' && steps.filter.outputs.src == 'true' }}
env:
NODE_OPTIONS: "--max_old_space_size=8192"
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Preview
if: ${{ github.ref != 'refs/heads/main' && steps.filter.outputs.src == 'true' }}
run: |
vercel deploy --prebuilt --archive=tgz --token=${{ secrets.VERCEL_TOKEN }}
echo "deploymentUrl=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT
- name: Deploy Production
if: ${{ github.ref == 'refs/heads/main' && steps.filter.outputs.src == 'true'}}
run: |
vercel deploy --prebuilt --archive=tgz --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Get Preview URL
if: ${{ github.ref != 'refs/heads/main' && steps.filter.outputs.src == 'true' }}
id: myRequest
uses: fjogeleit/http-request-action@v1
with:
url: 'https://api.vercel.com/v6/deployments?teamId=${{ secrets.VERCEL_ORG_ID }}&app=docs'
method: 'GET'
customHeaders: '{"Authorization": "Bearer ${{ secrets.VERCEL_TOKEN }}"}'
- uses: cloudposse/github-action-jq@main
if: ${{ github.ref != 'refs/heads/main' && steps.filter.outputs.src == 'true' }}
id: current
with:
compact: true
raw-output: true
input: ${{ steps.myRequest.outputs.response }}
script: |-
.deployments[] | select(.meta.githubCommitSha == "${{ github.sha }}") | .url
- uses: mshick/add-pr-comment@v2
if: ${{ github.ref != 'refs/heads/main' && steps.filter.outputs.src == 'true' }}
with:
message: |
Your build has completed!
[Preview deployment](https://${{ steps.current.outputs.output }})

View File

@ -1,6 +1,6 @@
{
"github": {
"enabled": false
"enabled": true
},
"cleanUrls": true,
"rewrites": [