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
name: Deploy site to Github Pages | |
# Runs when pushing new tags | |
on: | |
push: | |
branches: | |
- main | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Allow one concurrent deployment | |
concurrency: | |
group: "pages" | |
cancel-in-progress: true | |
jobs: | |
deps: | |
name: Install dependencies | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Cache application dependencies | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
key: ${{ runner.os }}-node-modules-${{ hashFiles('pnpm-lock.yaml') }} | |
path: | | |
node_modules | |
- name: Install pnpm | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 9 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: pnpm | |
- name: Install dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: pnpm install | |
audit: | |
name: Audit dependencies | |
runs-on: ubuntu-latest | |
needs: deps | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Restore application dependencies | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-node-modules-${{ hashFiles('pnpm-lock.yaml') }} | |
path: | | |
node_modules | |
fail-on-cache-miss: true | |
- name: Install pnpm | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 9 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: pnpm | |
- name: Perform dependency audit | |
run: pnpm audit | |
lint: | |
name: Lint code | |
runs-on: ubuntu-latest | |
needs: deps | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Restore application dependencies | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-node-modules-${{ hashFiles('pnpm-lock.yaml') }} | |
path: | | |
node_modules | |
fail-on-cache-miss: true | |
- name: Install pnpm | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 9 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: pnpm | |
- name: Perform code linting | |
run: pnpm lint | |
prettier: | |
name: Validate code formatting | |
runs-on: ubuntu-latest | |
needs: deps | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Restore application dependencies | |
uses: actions/cache/restore@v4 | |
id: cache | |
with: | |
key: ${{ runner.os }}-node-modules-${{ hashFiles('pnpm-lock.yaml') }} | |
path: | | |
node_modules | |
fail-on-cache-miss: true | |
- name: Install pnpm | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 9 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: pnpm | |
- name: Validate code formatting | |
run: pnpm prettier | |
# Build job | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
env: | |
NEXT_PUBLIC_BASE_URL: "https://codeaid.github.io" | |
NEXT_PUBLIC_BASE_PATH: "/cotw-tacklebox" | |
NEXT_PUBLIC_GOOGLE_ANALYTICS: "G-65MNFNW5EL" | |
needs: | |
- audit | |
- lint | |
- prettier | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Restore application dependencies | |
uses: actions/cache/restore@v4 | |
id: cache | |
with: | |
key: ${{ runner.os }}-node-modules-${{ hashFiles('pnpm-lock.yaml') }} | |
path: | | |
node_modules | |
fail-on-cache-miss: true | |
- name: Install pnpm | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 9 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: pnpm | |
- name: Configure GitHub Pages | |
uses: actions/configure-pages@v4 | |
with: | |
# Automatically inject basePath in your Next.js configuration file and disable | |
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized). | |
# | |
# You may remove this line if you want to manage the configuration yourself. | |
static_site_generator: next | |
- name: Configure output cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
.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') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}- | |
- name: Export static application assets | |
run: pnpm build | |
- name: Upload assets as artifacts | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: out | |
# Deployment job | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: build | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |