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

Vercel deploy in CI job; rename CI job #2229

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
50 changes: 49 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Squiggle packages checks
name: CI

on:
push:
Expand Down Expand Up @@ -52,3 +52,51 @@ jobs:
run: pnpm install
- name: Coverage
run: npx turbo run coverage

# TODO - prisma migrate

deploy:
# Based on https://vercel.com/guides/how-can-i-use-github-actions-with-vercel
name: Deploy to Vercel
runs-on: ubuntu-latest
needs: build-test-lint
environment:
name: Preview – squiggle-components
url: https://squiggle-components-pr-${{ github.event.pull_request.number }}-quantified-uncertainty.vercel.app
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_COMPONENTS_PROJECT_ID }} # TODO - make reusable
env: ${{ github.ref == 'refs/heads/main' && 'production' || 'preview' }}
dir: packages/components
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2

- uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'pnpm'

- name: Install dependencies
run: pnpm install

- name: Pull Vercel Environment Information
working-directory: ${{ env.dir }}
run: npx vercel pull --yes --environment=${{ env.env }} --token=${{ secrets.VERCEL_API_TOKEN }}

- name: Build Project Artifacts
working-directory: ${{ env.dir }}
run: npx vercel build --token=${{ secrets.VERCEL_API_TOKEN }}

- name: Deploy Project Artifacts to Vercel
working-directory: ${{ env.dir }}
# https://vercel.com/guides/how-to-alias-a-preview-deployment-using-the-cli
run: |
deploy_url=$(npx vercel deploy --prebuilt ${{ env.env == 'production' && '--prod' || '' }} --scope quantified-uncertainty --token=${{ secrets.VERCEL_API_TOKEN }})
vercel alias set "$deploy_url" squiggle-components-pr-${{ github.event.pull_request.number }}-quantified-uncertainty.vercel.app --scope quantified-uncertainty --token=${{ secrets.VERCEL_API_TOKEN }}
16 changes: 16 additions & 0 deletions .github/workflows/prisma-migrate-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,26 @@ on:
workflow_dispatch:

jobs:
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
steps:
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
prisma:
- 'packages/hub/prisma/migrations/**'

migrate:
needs: changes
if: needs.changes.outputs.prisma == 'true'
runs-on: ubuntu-latest
environment: Preview
steps:

- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ shell.nix
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.vercel
17 changes: 0 additions & 17 deletions .yarnrc.yml

This file was deleted.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
"prettier": "^3.0.0",
"turbo": "^1.10.12",
"turbo-ignore": "^1.10.12"
},
"dependencies": {
"vercel": "^31.2.3"
}
}
5 changes: 4 additions & 1 deletion packages/components/vercel.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"buildCommand": "PLATFORM=vercel npx turbo build",
"outputDirectory": "storybook-static",
"ignoreCommand": "npx turbo-ignore || ../../skip-dependabot.sh"
"ignoreCommand": "npx turbo-ignore || ../../skip-dependabot.sh",
"git": {
"deploymentEnabled": false
}
}
Loading