Hardcoded Google Analytics ID #17
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('yarn.lock') }} | |
path: | | |
node_modules | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: yarn | |
- name: Install dependencies | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: yarn 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('yarn.lock') }} | |
path: | | |
node_modules | |
fail-on-cache-miss: true | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: yarn | |
- name: Perform dependency audit | |
run: yarn 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('yarn.lock') }} | |
path: | | |
node_modules | |
fail-on-cache-miss: true | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: yarn | |
- name: Perform code linting | |
run: yarn 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('yarn.lock') }} | |
path: | | |
node_modules | |
fail-on-cache-miss: true | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: yarn | |
- name: Validate code formatting | |
run: yarn 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" | |
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('yarn.lock') }} | |
path: | | |
node_modules | |
fail-on-cache-miss: true | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: yarn | |
- 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('yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('yarn.lock') }}- | |
- name: Export static application assets | |
run: yarn 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 |