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

Migrate @kadena/docs to use Vercel CLI to deploy to preview environments. #2249

Closed
wants to merge 49 commits into from

Conversation

Ghislain89
Copy link
Contributor

@Ghislain89 Ghislain89 commented Jun 7, 2024

Deploy to Vercel using Vercel CLI instead of Vercel/Github Integration

Related Issue/Asana ticket: https://app.asana.com/0/1206316065856327/1207502646350161/f

Short description:
This PR adds preview deployments for @kadena/docs by using the Vercel CLI instead of relying on the Vercel/GitHub integration. This allows us to build our apps on GitHub runners and then upload prebuilt sources for deployment. For Docs this reduces deployment time from around 6-7 minutes to around 40-60 seconds. This should greatly reduce the time developers need to spent waiting for their deployment to be ready, especially when all other apps are migrated too

The deployment workflow uses turbo-ignore to check for differences between the current branch and the base branch to determine if a deployment for an app is required. If a deployment is required, the Vercel CLI wil pull environment variables, build the app, create a tgz archive and upload to Vercel after which a deployment will be triggered.

The deployment URL is then added to environments like so:
image

In short, this results in the following benefits:

  • Full control over Turbo Ignore and which branch we use to compare to when determining if a deployment is needed.
  • Faster App deployments as we don't need to wait on Vercel to fully rebuild our apps.
  • Many apps can be built in parallel, in Vercel only 2 (up to 12 if we pay more)
  • Developers don't need access to Vercel to deploy, they need to be able to run Workflows.
  • Deployment failures are echo'd in GitHub Actions instead of having to go to Vercel

Unfortunately, it's not all sunshine and rainbows there are also a few disadvantages. We lose branch-names for preview URLs. So instead of a branch name like https://alpha-docs-git-feat-kadena-clipactjs-kadena-js.vercel.app/, the generated preview url is more like https://alpha-docs-3dn06fmjg-kadena-js.vercel.app/

Tasks

  • Use Turbo Ignore to detect changes to base branch
  • Pull environment variables from preview
  • Deploy prebuilt artifact to Vercel
  • Add Preview URL to PR
  • Add Metadata to deployment to easily identify all deployments associated with a PR. Use <repository>-<pr_number>
  • Delete all preview environments associated with a PR when merging a PR
  • Refactor workflow to support Matrix runs for the individual apps

Test scenarios

  • Should deploy if changes have been detected to the package
  • Should deploy if dependencies have changed
  • Should Add deployment URL to PR
  • Should use the correct environment variables for the deployment

Reminders (if applicable)

  • I ran pnpm install and pnpm test in the root of the monorepo
    (optionally with --filter=...package... to exclude non-affected
    projects)
  • I ran pnpm changeset in the root of the monorepo
  • Test coverage has not decreased
  • Docs have been updated to reflect changes in PR (don't forget
    docs.kadena.io)

Copy link

changeset-bot bot commented Jun 7, 2024

⚠️ No Changeset found

Latest commit: ad28585

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Ghislain89 Ghislain89 marked this pull request as draft June 7, 2024 10:04
Copy link
Contributor

This PR is stale because it is open for 60 days with no activity

@Randynamic
Copy link
Contributor

@alber70g your call

Copy link
Contributor

github-actions bot commented Nov 3, 2024

This PR is stale because it is open for 60 days with no activity

@Ghislain89
Copy link
Contributor Author

Based on recent features in Vercel this PR shouldn't be needed anymore. It's unlikely that the added benefit outweighs the maintenance and complexity.

@Ghislain89 Ghislain89 closed this Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants