build: always run test-staging #147
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: Main Workflow | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
validate: | |
name: Validate Using Latest Node LTS | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Run Lint and Typecheck | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.18.2 | |
cache: pnpm | |
- run: pnpm install --frozen-lockfile | |
- run: pnpm lint | |
- run: pnpm typecheck | |
build: | |
name: Build website | |
runs-on: ubuntu-latest | |
needs: validate | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Download build cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ github.workspace }}/.next/cache | |
# Generate a new cache whenever packages or source files change. | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx', '**.scss') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- | |
- name: Build website | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: pnpm | |
- run: pnpm install --frozen-lockfile | |
- run: pnpm build | |
- name: Save build folder | |
uses: actions/upload-artifact@v3 | |
with: | |
name: out | |
if-no-files-found: error | |
path: out | |
test-staging: | |
name: Test Staging | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Download the build folders | |
uses: actions/download-artifact@v3 | |
with: | |
name: out | |
path: out | |
- name: Install dependencies and playwright browsers | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.18.2 | |
cache: pnpm | |
- run: pnpm install --frozen-lockfile | |
- run: pnpm exec playwright install --with-deps | |
- run: pnpm start-static & | |
- run: pnpm exec playwright test | |
- uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: playwright-report | |
path: playwright-report/ | |
retention-days: 30 | |
deploy: | |
name: Deploy to mlaursen.com | |
if: ${{ github.ref == 'refs/heads/main' }} | |
runs-on: ubuntu-latest | |
needs: test-staging | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# this is required so that the github-pages-deploy-action works | |
# for some reason | |
with: | |
persist-credentials: false | |
- name: Download build folder | |
uses: actions/download-artifact@v3 | |
with: | |
name: out | |
path: out | |
- name: Deploy to gh-pages | |
uses: JamesIves/github-pages-deploy-action@v4.4.1 | |
with: | |
branch: gh-pages | |
folder: out |