Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: vercel scripts #1492

Merged
merged 26 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,7 @@ module.exports = {
indent: "off",
"object-shorthand": ["error"],
"deprecation/deprecation": "error",
"import/no-internal-modules": [
"error",
{
forbid: ["@fern-ui/*/**"],
},
],
// "import/no-internal-modules": ["error"],
eqeqeq: [
"error",
"always",
Expand Down
8 changes: 3 additions & 5 deletions .github/actions/ete-docs-bundle/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ runs:
shell: bash
env:
DEPLOYMENT_URL: ${{ inputs.deployment_url }}
run: pnpm exec playwright test playwright/smoke --workers 6
run: PLAYWRIGHT_JSON_OUTPUT_NAME=results.json pnpm exec playwright test playwright/smoke --workers 6 --reporter json

- uses: actions/upload-artifact@v4
- uses: daun/playwright-report-summary@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
report-file: results.json
111 changes: 0 additions & 111 deletions .github/actions/vercel/action.yml

This file was deleted.

45 changes: 31 additions & 14 deletions .github/workflows/deploy-docs-bundle-dev.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
name: Deploy @fern-ui/docs-bundle (dev)
env:
VERCEL_ORG_ID: team_6FKOM5nw037hv8g2mTk3gaH7
VERCEL_PROJECT_ID: prj_QnsiTm1ijJP6cS23K5da6lL02wbp
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: "buildwithfern"

on:
push:
Expand All @@ -14,24 +8,47 @@ on:

concurrency:
group: app-dev.buildwithfern.com
cancel-in-progress: ${{ github.event_name == 'push' }}
cancel-in-progress: true

jobs:
ignore:
runs-on: ubuntu-latest
outputs:
continue: ${{ steps.ignore.outputs.continue }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # used for turbo-ignore

- name: Install
uses: ./.github/actions/install
with:
run_install: false

- name: Ignore unchanged files
id: ignore
run: set +e; pnpx turbo-ignore @fern-ui/docs-bundle --fallback=HEAD^1; echo "continue=$?" >> $GITHUB_OUTPUT

deploy:
if: github.ref_name == 'main'
needs: ignore
if: needs.ignore.outputs.continue == 1
runs-on: ubuntu-latest
environment:
name: Production - app-dev.buildwithfern.com
url: ${{ steps.deploy.outputs.deployment_url }}
outputs:
deployment_url: ${{ steps.deploy.outputs.deployment_url }}
steps:
# set the ref to a specific branch so that the deployment is scoped to that branch (instead of a headless ref)
- uses: actions/checkout@v4
- name: Build & Deploy to Vercel
uses: ./.github/actions/vercel
id: deploy
with:
ref: ${{ github.ref_name || github.ref }}
package: "@fern-ui/docs-bundle"
environment: production
promote: true

- name: Install
uses: ./.github/actions/install

- name: Build & Deploy to Vercel
id: deploy
run: |
pnpm vercel-scripts deploy app-dev.buildwithfern.com --token=${{ secrets.VERCEL_TOKEN }} --environment=production --force
echo "deployment_url=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT
96 changes: 58 additions & 38 deletions .github/workflows/deploy-docs-bundle-preview.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
name: Preview @fern-ui/docs-bundle
env:
VERCEL_ORG_ID: team_6FKOM5nw037hv8g2mTk3gaH7
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: "buildwithfern"

on:
pull_request:
Expand All @@ -12,32 +7,60 @@ on:
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name || github.ref }}
cancel-in-progress: false

jobs:
ignore:
runs-on: ubuntu-latest
outputs:
continue: ${{ steps.ignore.outputs.continue }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # used for turbo-ignore

- name: Install
uses: ./.github/actions/install
with:
run_install: false

- name: Ignore unchanged files
id: ignore
run: set +e; pnpx turbo-ignore @fern-ui/docs-bundle --fallback=HEAD^1; echo "continue=$?" >> $GITHUB_OUTPUT

deploy:
needs: ignore
if: needs.ignore.outputs.continue == 1
runs-on: ubuntu-latest
environment:
name: Preview - app.buildwithfern.com
url: ${{ steps.deploy.outputs.deployment_url }}
outputs:
deployment_url: ${{ steps.deploy.outputs.deployment_url }}
permissions: write-all
permissions: write-all # required for the pr-preview comment
steps:
# set the ref to a specific branch so that the deployment is scoped to that branch (instead of a headless ref)
- uses: actions/checkout@v4
with:
fetch-depth: 2 # used for turbo-ignore
ref: ${{ github.event.pull_request.head.ref || github.ref_name || github.ref }}

- name: Install
uses: ./.github/actions/install

- name: Build & Deploy to Vercel
uses: ./.github/actions/vercel
id: deploy
env:
ANALYZE: 1
VERCEL_PROJECT_ID: prj_QX3venU6jwRUmdt8ArfL8AU5r1d4
run: |
pnpm vercel-scripts deploy app.buildwithfern.com --token=${{ secrets.VERCEL_TOKEN }}
if [ -f deployment-url.txt ]; then
pnpm vercel-scripts preview.txt $(cat deployment-url.txt) --token=${{ secrets.VERCEL_TOKEN }}
echo "deployment_url=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT
fi

- name: Comment PR Preview
uses: thollander/actions-comment-pull-request@v2
if: github.event_name == 'pull_request' && steps.deploy.outputs.deployment_url
with:
ref: ${{ github.event.pull_request.head.ref || github.ref_name || github.ref }}
package: "@fern-ui/docs-bundle"
environment: preview
force: ${{ github.event_name == 'workflow_dispatch' }}
filePath: preview.txt
comment_tag: pr_preview

- name: Analyze bundle
if: steps.deploy.outputs.deployment_url
Expand Down Expand Up @@ -71,45 +94,42 @@ jobs:
comment_tag: bundle_analysis

deploy-dev:
needs: ignore
if: needs.ignore.outputs.continue == 1
runs-on: ubuntu-latest
environment:
name: Preview - app-dev.buildwithfern.com
url: ${{ steps.deploy.outputs.deployment_url }}
outputs:
deployment_url: ${{ steps.deploy.outputs.deployment_url }}
steps:
# set the ref to a specific branch so that the deployment is scoped to that branch (instead of a headless ref)
- uses: actions/checkout@v4
- name: Build & Deploy to Vercel
uses: ./.github/actions/vercel
id: deploy
env:
VERCEL_PROJECT_ID: prj_QnsiTm1ijJP6cS23K5da6lL02wbp
with:
ref: ${{ github.event.pull_request.head.ref || github.ref_name || github.ref }}
package: "@fern-ui/docs-bundle"
environment: preview

- name: Install
uses: ./.github/actions/install

- name: Build & Deploy to Vercel
id: deploy
run: |
pnpm vercel-scripts deploy app-dev.buildwithfern.com --token=${{ secrets.VERCEL_TOKEN }}
echo "deployment_url=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT

ete:
needs: deploy # only runs on fern-prod
if: needs.deploy.outputs.deployment_url
runs-on: ubuntu-latest
permissions: write-all
permissions: write-all # required for the playwright-report-summary action
steps:
- uses: actions/checkout@v4

# this script generates domains.txt and preview.txt
- name: Generate preview URLs
env:
DEPLOYMENT_URL: ${{ needs.deploy.outputs.deployment_url }}
PR_PREVIEW: ${{ github.event_name == 'pull_request' }}
run: node scripts/fetch-domains.js
- name: Install
uses: ./.github/actions/install

- name: Comment PR Preview
uses: thollander/actions-comment-pull-request@v2
if: github.event_name == 'pull_request'
with:
filePath: preview.txt
comment_tag: pr_preview
- name: Fetch domains
run: pnpm vercel-scripts domains.txt ${{ needs.deploy.outputs.deployment_url }} --token=${{ secrets.VERCEL_TOKEN }}

- name: Run E2E tests
uses: ./.github/actions/ete-docs-bundle
Expand Down
Loading
Loading