Skip to content

Build, test and deploy to production #329

Build, test and deploy to production

Build, test and deploy to production #329

name: Build, test and deploy to production
on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
# runs "every wednesday at 15h GMT" (https://crontab.guru)
- cron: "0 14 * * 3"
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
matrix:
node-version: [18.16.0]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build app
run: yarn build
- name: Run unit tests
run: yarn test
- name: Run linter
run: yarn lint
lighthouse-desktop:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: build
strategy:
matrix:
node-version: [18.16.0]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build app
run: yarn build
- name: Run Lighthouse CI desktop
run: yarn run:lighthouse:all:desktop
lighthouse-mobile:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: build
strategy:
matrix:
node-version: [18.16.0]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build app
run: yarn build
- name: Run Lighthouse CI mobile
run: yarn run:lighthouse:all:mobile
playwright-chrome:
runs-on: ubuntu-latest
timeout-minutes: 20
needs: build
container:
image: mcr.microsoft.com/playwright:v1.36.1-focal
strategy:
matrix:
node-version: [18.16.0]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build app
run: yarn build
- name: Run Playwright tests
run: yarn run:playwright:chrome
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODEMAILER_SEND_EMAIL_FROM: ${{ secrets.NODEMAILER_SEND_EMAIL_FROM }}
NODEMAILER_SEND_EMAIL_FROM_PASS: ${{ secrets.NODEMAILER_SEND_EMAIL_FROM_PASS }}
NODEMAILER_SEND_EMAIL_TO: ${{ secrets.NODEMAILER_SEND_EMAIL_TO }}
NEXT_PUBLIC_IS_PLAYWRIGHT: ${{ secrets.NEXT_PUBLIC_IS_PLAYWRIGHT }}
NEXT_PUBLIC_MOCK_CONTACT_FORM_SUCCESS: ${{ secrets.NEXT_PUBLIC_MOCK_CONTACT_FORM_SUCCESS }}
NEXT_PUBLIC_MOCK_CONTACT_FORM_ERROR: ${{ secrets.NEXT_PUBLIC_MOCK_CONTACT_FORM_ERROR }}
- name: Upload snapshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: playwright-chrome-test-results
path: "e2e/test-results"
playwright-edge:
runs-on: ubuntu-latest
timeout-minutes: 20
needs: build
container:
image: mcr.microsoft.com/playwright:v1.36.1-focal
strategy:
matrix:
node-version: [18.16.0]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build app
run: yarn build
- name: Run Playwright tests
run: yarn run:playwright:edge
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODEMAILER_SEND_EMAIL_FROM: ${{ secrets.NODEMAILER_SEND_EMAIL_FROM }}
NODEMAILER_SEND_EMAIL_FROM_PASS: ${{ secrets.NODEMAILER_SEND_EMAIL_FROM_PASS }}
NODEMAILER_SEND_EMAIL_TO: ${{ secrets.NODEMAILER_SEND_EMAIL_TO }}
NEXT_PUBLIC_IS_PLAYWRIGHT: ${{ secrets.NEXT_PUBLIC_IS_PLAYWRIGHT }}
NEXT_PUBLIC_MOCK_CONTACT_FORM_SUCCESS: ${{ secrets.NEXT_PUBLIC_MOCK_CONTACT_FORM_SUCCESS }}
NEXT_PUBLIC_MOCK_CONTACT_FORM_ERROR: ${{ secrets.NEXT_PUBLIC_MOCK_CONTACT_FORM_ERROR }}
- name: Upload snapshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: playwright-edge-test-results
path: "e2e/test-results"
playwright-firefox:
runs-on: ubuntu-latest
timeout-minutes: 20
needs: build
container:
image: mcr.microsoft.com/playwright:v1.36.1-focal
strategy:
matrix:
node-version: [18.16.0]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build app
run: yarn build
- name: Run Playwright tests
run: HOME=/root yarn run:playwright:firefox
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODEMAILER_SEND_EMAIL_FROM: ${{ secrets.NODEMAILER_SEND_EMAIL_FROM }}
NODEMAILER_SEND_EMAIL_FROM_PASS: ${{ secrets.NODEMAILER_SEND_EMAIL_FROM_PASS }}
NODEMAILER_SEND_EMAIL_TO: ${{ secrets.NODEMAILER_SEND_EMAIL_TO }}
NEXT_PUBLIC_IS_PLAYWRIGHT: ${{ secrets.NEXT_PUBLIC_IS_PLAYWRIGHT }}
NEXT_PUBLIC_MOCK_CONTACT_FORM_SUCCESS: ${{ secrets.NEXT_PUBLIC_MOCK_CONTACT_FORM_SUCCESS }}
NEXT_PUBLIC_MOCK_CONTACT_FORM_ERROR: ${{ secrets.NEXT_PUBLIC_MOCK_CONTACT_FORM_ERROR }}
- name: Upload snapshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: playwright-firefox-test-results
path: "e2e/test-results"
playwright-safari:
runs-on: ubuntu-latest
timeout-minutes: 20
needs: build
container:
image: mcr.microsoft.com/playwright:v1.36.1-focal
strategy:
matrix:
node-version: [18.16.0]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build app
run: yarn build
- name: Run Playwright tests
run: yarn run:playwright:safari
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODEMAILER_SEND_EMAIL_FROM: ${{ secrets.NODEMAILER_SEND_EMAIL_FROM }}
NODEMAILER_SEND_EMAIL_FROM_PASS: ${{ secrets.NODEMAILER_SEND_EMAIL_FROM_PASS }}
NODEMAILER_SEND_EMAIL_TO: ${{ secrets.NODEMAILER_SEND_EMAIL_TO }}
NEXT_PUBLIC_IS_PLAYWRIGHT: ${{ secrets.NEXT_PUBLIC_IS_PLAYWRIGHT }}
NEXT_PUBLIC_MOCK_CONTACT_FORM_SUCCESS: ${{ secrets.NEXT_PUBLIC_MOCK_CONTACT_FORM_SUCCESS }}
NEXT_PUBLIC_MOCK_CONTACT_FORM_ERROR: ${{ secrets.NEXT_PUBLIC_MOCK_CONTACT_FORM_ERROR }}
- name: Upload snapshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: playwright-safari-test-results
path: "e2e/test-results"
playwright-chrome-mobile:
runs-on: ubuntu-latest
timeout-minutes: 20
needs: build
container:
image: mcr.microsoft.com/playwright:v1.36.1-focal
strategy:
matrix:
node-version: [18.16.0]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build app
run: yarn build
- name: Run Playwright tests
run: yarn run:playwright:chrome:mobile
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODEMAILER_SEND_EMAIL_FROM: ${{ secrets.NODEMAILER_SEND_EMAIL_FROM }}
NODEMAILER_SEND_EMAIL_FROM_PASS: ${{ secrets.NODEMAILER_SEND_EMAIL_FROM_PASS }}
NODEMAILER_SEND_EMAIL_TO: ${{ secrets.NODEMAILER_SEND_EMAIL_TO }}
NEXT_PUBLIC_IS_PLAYWRIGHT: ${{ secrets.NEXT_PUBLIC_IS_PLAYWRIGHT }}
NEXT_PUBLIC_MOCK_CONTACT_FORM_SUCCESS: ${{ secrets.NEXT_PUBLIC_MOCK_CONTACT_FORM_SUCCESS }}
NEXT_PUBLIC_MOCK_CONTACT_FORM_ERROR: ${{ secrets.NEXT_PUBLIC_MOCK_CONTACT_FORM_ERROR }}
- name: Upload snapshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: playwright-chrome-mobile-test-results
path: "e2e/test-results"
playwright-safari-mobile:
runs-on: ubuntu-latest
timeout-minutes: 20
needs: build
container:
image: mcr.microsoft.com/playwright:v1.36.1-focal
strategy:
matrix:
node-version: [18.16.0]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use node ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build app
run: yarn build
- name: Run Playwright tests
run: yarn run:playwright:safari:mobile
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODEMAILER_SEND_EMAIL_FROM: ${{ secrets.NODEMAILER_SEND_EMAIL_FROM }}
NODEMAILER_SEND_EMAIL_FROM_PASS: ${{ secrets.NODEMAILER_SEND_EMAIL_FROM_PASS }}
NODEMAILER_SEND_EMAIL_TO: ${{ secrets.NODEMAILER_SEND_EMAIL_TO }}
NEXT_PUBLIC_IS_PLAYWRIGHT: ${{ secrets.NEXT_PUBLIC_IS_PLAYWRIGHT }}
NEXT_PUBLIC_MOCK_CONTACT_FORM_SUCCESS: ${{ secrets.NEXT_PUBLIC_MOCK_CONTACT_FORM_SUCCESS }}
NEXT_PUBLIC_MOCK_CONTACT_FORM_ERROR: ${{ secrets.NEXT_PUBLIC_MOCK_CONTACT_FORM_ERROR }}
- name: Upload snapshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: playwright-safari-mobile-test-results
path: "e2e/test-results"
deploy:
runs-on: ubuntu-latest
timeout-minutes: 15
needs:
[
lighthouse-desktop,
lighthouse-mobile,
playwright-chrome,
playwright-edge,
playwright-firefox,
playwright-safari,
playwright-chrome-mobile,
playwright-safari-mobile,
]
if: github.ref == 'refs/heads/master' && github.event.schedule != '0 14 * * 3' && !contains(github.event.head_commit.message, 'chore') && !contains(github.event.head_commit.message, 'test') && !contains(github.event.head_commit.message, 'docs') && !contains(github.event.head_commit.message, 'ci')
steps:
- uses: actions/checkout@v3
- name: Deploy to Vercel
run: npx vercel --token ${VERCEL_TOKEN} --prod
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}