fix: replace uuid package with Node.js crypto.randomUUID() for Render… #624
This file contains hidden or 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: Frontend CI/CD | |
on: | |
push: | |
branches: [main, develop] | |
pull_request: | |
branches: [main, develop] | |
permissions: | |
contents: read | |
issues: write | |
pull-requests: write | |
env: | |
NODE_VERSION: "18.x" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: "npm" | |
cache-dependency-path: package-lock.json | |
- name: Cache node_modules | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node-${{ matrix.node-version }}-deps-${{ hashFiles('package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node-${{ matrix.node-version }}-deps- | |
- name: Cache .next build | |
uses: actions/cache@v4 | |
with: | |
path: .next | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('package-lock.json') }}- | |
- name: Install dependencies | |
run: npm ci --legacy-peer-deps | |
- name: Run linting | |
run: npm run lint:ci | |
- name: Build Next.js application | |
run: npm run build | |
env: | |
CI: true | |
NODE_ENV: production | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-${{ matrix.node-version }} | |
path: .next/ | |
retention-days: 7 | |
security-audit: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: "npm" | |
cache-dependency-path: package-lock.json | |
- name: Install dependencies | |
run: npm ci --legacy-peer-deps | |
- name: Run security audit | |
run: npm audit --audit-level moderate --legacy-peer-deps | |
deploy-preview: | |
runs-on: ubuntu-latest | |
needs: [build, security-audit] | |
if: github.event_name == 'pull_request' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
cache: "npm" | |
cache-dependency-path: package-lock.json | |
- name: Install dependencies | |
run: npm ci --legacy-peer-deps | |
- name: Run linting | |
run: npm run lint:ci | |
- name: Build for preview | |
run: npm run build | |
env: | |
NODE_ENV: production | |
- name: Comment PR with build status | |
uses: actions/github-script@v7 | |
continue-on-error: true | |
with: | |
script: | | |
try { | |
await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '✅ **Frontend CI/CD Pipeline Completed Successfully!**\n\n- ✅ Linting passed\n- ✅ Build completed\n- ✅ Security audit passed\n\nReady for review and deployment! 🚀' | |
}); | |
} catch (error) { | |
console.log('Could not comment on PR:', error.message); | |
throw error; | |
} |