Skip to content

Conversation

@Alessandro100
Copy link
Contributor

@Alessandro100 Alessandro100 commented Jan 28, 2026

Introduces CICD setup for Vercel deployments. This is the github actions aspect of it, there were a

Vercel Settings (Not reflected in PR)

  • Bot Protection: currently only logging, if issue, we can set to block
  • Set environment variables for: production, staging, and preview

Github Actions Summary

On PR to main -> code checks, deploy preview url (DEV), lighthouse check
Once code is in main -> Vercel branching strategy will automatically deploy to the staging environment (QA)
Productions has 3 ways to deploy

  1. A github release
  2. Manually triggering the prod-on-release action from Github
  3. In Vercel, promoting the staging environment

Note about the prototype workflow

I copied functionality from our previous cicd, with the exception of prototypes. Because the .env vars live on Vercel, to mimic functionality of previous prototyping we would need to create 3 environments dev/qa/prod-prototype. As this was workflow / environment was not frequently used, I omitted it from this PR and is something to evaluate in the future

@Alessandro100 Alessandro100 self-assigned this Jan 28, 2026
@vercel
Copy link

vercel bot commented Jan 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mobilitydatabase-web Ready Ready Preview, ✅ 2 resolved Jan 30, 2026 4:12pm

Request Review

@github-actions
Copy link

github-actions bot commented Jan 29, 2026

*Lighthouse ran on https://mobilitydatabase-3tecx7whc-mobility-data.vercel.app/ * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟢 100 🟢 100 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-3tecx7whc-mobility-data.vercel.app/feeds * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟢 100 🟢 100 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-3tecx7whc-mobility-data.vercel.app/feeds/gtfs/mdb-2126 * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟠 67 🟢 98 🟢 96 🟠 88

*Lighthouse ran on https://mobilitydatabase-3tecx7whc-mobility-data.vercel.app/feeds/gtfs_rt/mdb-2585 * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟠 89 🟠 87 🟢 100 🟠 88

*Lighthouse ran on https://mobilitydatabase-3tecx7whc-mobility-data.vercel.app/gbfs/gbfs-flamingo_porirua * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟢 100 🟢 100 🟢 96 🟢 100

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces Vercel deployment automation through GitHub Actions, replacing the previous standalone Next.js output configuration. The changes implement a three-tiered deployment strategy: preview deployments for pull requests using the DEV environment, automatic staging deployments for the main branch (via Vercel's branching), and production deployments triggered by GitHub releases or manual workflow dispatch.

Changes:

  • Migrated from static robots.txt files to dynamic Next.js robots() function based on Vercel environment
  • Replaced hardcoded API URLs in MSW handlers with wildcard patterns for environment flexibility
  • Removed standalone output mode from Next.js config for Vercel compatibility
  • Added GitHub Actions workflows for preview deployments (with Lighthouse checks) and production releases
  • Enhanced test setup with Firebase Auth mocks and environment detection improvements

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/setupTests.ts Added Firebase Auth provider mocks and polyfills for test environment
src/mocks/handlers.ts Switched from environment-based URLs to wildcard patterns for API mocking
src/lib/firebase-admin.ts Formatting change (line break) for consistency
src/app/robots.ts New dynamic robots.txt generation based on Vercel environment variable
src/app/layout.tsx Added environment-aware robots meta tags
src/app/context/RemoteConfigProvider.spec.tsx Removed entire test file
public/robots.txt Deleted static production robots file
public/robots.staging.txt Deleted static staging robots file
package.json Specified Node.js 24.x engine requirement
next.config.mjs Removed standalone output mode and commented assetPrefix
cypress.config.ts Improved CI detection logic for environment selection
.github/workflows/verecl-prod-on-release.yml New workflow for production deployments via releases
.github/workflows/vercel-preview-pr.yml New workflow for PR preview deployments with quality checks
.github/workflows/README.md Documentation for deployment workflows
.github/lighthouserc.js Lighthouse CI configuration for performance testing
.github/config.yml GitHub bot configuration for welcoming new contributors
.github/PULL_REQUEST_TEMPLATE.md Standardized PR template with checklist
Comments suppressed due to low confidence (1)

src/app/context/RemoteConfigProvider.spec.tsx:1

  • The entire test file for userHasBypass function has been deleted. Ensure that equivalent test coverage exists elsewhere for the bypass configuration logic, or consider whether this functionality still exists and needs testing.


- name: Format lighthouse score
id: format_lighthouse_score
uses: actions/github-script@v3
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The action actions/github-script@v3 is outdated. The latest stable version is v7. Consider updating to actions/github-script@v7 for better performance and security.

Suggested change
uses: actions/github-script@v3
uses: actions/github-script@v7

Copilot uses AI. Check for mistakes.
disabled: false
},
extraHeaders: JSON.stringify({
'x-vercel-protection-bypass': String(process.env.VERCEL_AUTOMATION_BYPASS_SECRET)
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If VERCEL_AUTOMATION_BYPASS_SECRET is undefined, this will set the header value to the string 'undefined'. This should handle the undefined case explicitly or ensure the environment variable is always set.

Copilot uses AI. Check for mistakes.
Alessandro100 and others added 2 commits January 29, 2026 13:59
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove the types here to avoid confusion; by default, only the listed types are executed.

@@ -0,0 +1,147 @@
name: Vercel Preview (PR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove "Vercel" from the file name and title. We can use this workflow to run lint, unit tests, Cypress tests, and other checks that do not necessarily involve Vercel.

jobs:
deploy_preview:
# ✅ Only run for same-repo PRs (not forks)
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use this workflow to run all the checks, such as lint, unit tests, and Cypress. The condition should be applied only in the step that deploys the preview to Vercel.

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 24.12.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick]: create a variable with the node version within the workflow and replace the value here and other places that is used(the same for the other workflow), example

run: npm i -g vercel@latest

- name: Pull environment variables from Vercel for e2e tests
run: vercel env pull .env.local --environment=preview --yes --token=${{ env.VERCEL_TOKEN }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question]: Do we need to access the Vercel configuration to run the Cypress tests? If yes, this will be an issue with developers that don't have access to Vercel and also in forks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do for the only reason of getting the .env variables. You do have a point that they will not be able to run this. Lets create a ticket on how we can mock services in the e2e test to not require a .env file so that it's easier to run. This could also be an extension to create a mock server for dev environment without .env secrets

@@ -0,0 +1,16 @@
import { type MetadataRoute } from 'next';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this correctly, the robots.txt is implemented as a server-side component. If this is true, then my comment:
The robots.txt file is highly used and doesn't change at runtime. This file is intrinsic static per environment. It's preferable to have one file per environment and manage the deployment of the correct one during build time instead of having a server-side function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nextjs is smart in that it detects that it's a static file and prerenders it at build time. Double checked after a yarn build:prod

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is robots.txt a file or a folder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants