Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.

Merge pull request #78 from hack-rpi/ethantamang-updateColorsFurtherFAQ #214

Merge pull request #78 from hack-rpi/ethantamang-updateColorsFurtherFAQ

Merge pull request #78 from hack-rpi/ethantamang-updateColorsFurtherFAQ #214

Workflow file for this run

name: Build NextJS Site
on:
push:
branches: ["main"]
paths-ignore:
- '**/*.md'
- 'docs/**'
pull_request:
branches: ["main", "develop"]
paths-ignore:
- '**/*.md'
- 'docs/**'
# Set minimal permissions (security best practice)
permissions: {}
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# Improved to cancel in-progress PR builds but preserve main builds
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
# Detect file changes to optimize what jobs run
changes:
runs-on: ubuntu-latest
# Grant permissions to create check runs (needed for action outputs)
permissions:
checks: read
contents: read
pull-requests: read
outputs:
code: ${{ steps.filter.outputs.code }}
styles: ${{ steps.filter.outputs.styles }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
code:
- '**/*.{js,jsx,ts,tsx}'
- 'package.json'
- 'package-lock.json'
- 'yarn.lock'
styles:
- '**/*.{css,scss}'
- 'tailwind.config.{js,ts}'
# Lint and format job
lint:
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.code == 'true' || github.event_name == 'pull_request' }}
# Grant specific permissions needed for lint job
permissions:
checks: write
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
# Full git history is needed for proper linting
fetch-depth: 0
- name: Prettify code
uses: creyD/prettier_action@v4.3
with:
prettier_options: --write --tab-width=2 --use-tabs .
# Ensure Prettier config is respected or created if missing
prettier_plugins: prettier-plugin-tailwindcss
github_token: ${{ secrets.GITHUB_TOKEN }}
commit_message: "🧹 Automated code formatting"
# Skip committing on main branch to avoid repository rule violations
same_commit: true
# Only commit changes when not on main branch
commit_options: ${{ github.ref != 'refs/heads/main' && '--no-verify' || '' }}
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: ${{ steps.detect-package-manager.outputs.manager }}
# Optimized caching strategy
- name: Cache node_modules
uses: actions/cache@v4
id: node-modules-cache
with:
path: node_modules
key: ${{ runner.os }}-${{ steps.detect-package-manager.outputs.manager }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-v2
- name: Install dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Install additional dependencies for linting
run: |
${{ steps.detect-package-manager.outputs.manager }} add --save-dev eslint-plugin-prettier prettier-plugin-tailwindcss
# Enhanced linting strategy - auto-fix but don't fail on warnings
- name: Run ESLint with auto-fix
id: eslint-fix
continue-on-error: true
run: |
echo "Running ESLint with auto-fix..."
${{ steps.detect-package-manager.outputs.runner }} next lint --fix
# Check for errors, but allow warnings
- name: Check for ESLint errors
run: |
echo "Checking for ESLint errors (allowing warnings)..."
${{ steps.detect-package-manager.outputs.runner }} next lint --quiet || {
echo "::error::ESLint found errors that must be fixed. Please review the errors above.";
exit 1;
}
# Report warnings but don't fail the build
- name: Report ESLint warnings
run: |
echo "Checking for ESLint warnings (won't fail build)..."
${{ steps.detect-package-manager.outputs.runner }} next lint || echo "::warning::ESLint found warnings, but continuing build. Please consider fixing these warnings when possible."
# Build job - preserved your logic with optimizations
build:
runs-on: ubuntu-latest
needs: [lint]
timeout-minutes: 15
# Grant specific permissions needed for build job
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: ${{ steps.detect-package-manager.outputs.manager }}
# Reusing improved caching from above
- name: Cache node_modules
uses: actions/cache@v4
id: node-modules-cache
with:
path: node_modules
key: ${{ runner.os }}-${{ steps.detect-package-manager.outputs.manager }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-v2
- name: Restore Next.js build cache
uses: actions/cache@v4
with:
path: |
.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/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('**/package-lock.json', '**/yarn.lock') }}-
- name: Install dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} --no-audit --force
# Preserved from original workflow
- name: Add Amplify outputs file
run: touch amplify_outputs.json
- name: Populate Amplify outputs file
run: echo "{}" > amplify_outputs.json
- name: Build with Next.js
run: ${{ steps.detect-package-manager.outputs.runner }} next build
env:
NODE_OPTIONS: --max-old-space-size=4096 --no-deprecation
# Test job
test:
runs-on: ubuntu-latest
needs: [changes]
if: ${{ needs.changes.outputs.code == 'true' || github.event_name == 'pull_request' }}
# Grant specific permissions needed for test job
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Cache node_modules
uses: actions/cache@v4
id: node-modules-cache
with:
path: node_modules
key: ${{ runner.os }}-${{ steps.detect-package-manager.outputs.manager }}-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-v2
- name: Install dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} --no-audit --force
# Added Amplify file creation steps
- name: Add Amplify outputs file
run: touch amplify_outputs.json
- name: Populate Amplify outputs file
run: echo "{}" > amplify_outputs.json
- name: Run unit tests (excluding E2E tests)
run: ${{ steps.detect-package-manager.outputs.manager }} test -- --testPathIgnorePatterns="e2e"
- name: Display E2E test instructions
run: |
echo "========== E2E TESTS SHOULD BE RUN MANUALLY =========="
echo "As requested, E2E tests are excluded from CI and should be run manually by developers"
echo "To run E2E tests locally, use: npx playwright test"
echo "======================================================"