|
1 |
| -# Sample workflow for building and deploying a Next.js site to GitHub Pages |
2 |
| -# |
3 |
| -# To get started with Next.js see: https://nextjs.org/docs/getting-started |
4 |
| -# |
5 |
| -name: Test Next.JS build |
| 1 | +name: ESLint |
6 | 2 |
|
7 | 3 | on:
|
8 |
| - # Runs on pushes targeting the default branch |
9 | 4 | push:
|
10 | 5 | branches: ["main"]
|
11 |
| - |
12 | 6 | pull_request:
|
13 | 7 | branches: ["main"]
|
14 |
| - |
15 |
| - # Allows you to run this workflow manually from the Actions tab |
16 |
| - workflow_dispatch: |
17 |
| - |
18 |
| -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
19 |
| -permissions: |
20 |
| - contents: read |
21 |
| - id-token: write |
22 |
| - |
23 |
| -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
24 |
| -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
25 |
| -concurrency: |
26 |
| - group: "pages" |
27 |
| - cancel-in-progress: false |
| 8 | + schedule: |
| 9 | + - cron: "25 21 * * 4" |
28 | 10 |
|
29 | 11 | jobs:
|
30 |
| - # Build job |
31 |
| - build: |
| 12 | + eslint: |
| 13 | + name: Run ESLint Scanning |
32 | 14 | runs-on: ubuntu-latest
|
| 15 | + permissions: |
| 16 | + contents: read |
| 17 | + security-events: write |
| 18 | + actions: read |
33 | 19 | steps:
|
34 |
| - - name: Checkout |
35 |
| - uses: actions/checkout@v4 |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v3 |
| 22 | + |
36 | 23 | - name: Detect package manager
|
37 | 24 | id: detect-package-manager
|
38 | 25 | run: |
|
39 | 26 | if [ -f "${{ github.workspace }}/yarn.lock" ]; then
|
40 | 27 | echo "manager=yarn" >> $GITHUB_OUTPUT
|
41 |
| - echo "command=install" >> $GITHUB_OUTPUT |
| 28 | + echo "install-command=install" >> $GITHUB_OUTPUT |
42 | 29 | echo "runner=yarn" >> $GITHUB_OUTPUT
|
43 | 30 | exit 0
|
44 |
| - elif [ -f "${{ github.workspace }}/package.json" ]; then |
| 31 | + elif [ -f "${{ github.workspace }}/package-lock.json" ]; then |
45 | 32 | echo "manager=npm" >> $GITHUB_OUTPUT
|
46 |
| - echo "command=ci" >> $GITHUB_OUTPUT |
47 |
| - echo "runner=npx --no-install" >> $GITHUB_OUTPUT |
| 33 | + echo "install-command=ci" >> $GITHUB_OUTPUT |
| 34 | + echo "runner=npx" >> $GITHUB_OUTPUT |
48 | 35 | exit 0
|
49 | 36 | else
|
50 | 37 | echo "Unable to determine package manager"
|
51 | 38 | exit 1
|
52 | 39 | fi
|
53 |
| - - name: Setup Node |
| 40 | +
|
| 41 | + - name: Setup Node.js |
54 | 42 | uses: actions/setup-node@v4
|
55 | 43 | with:
|
56 | 44 | node-version: "20"
|
57 | 45 | cache: ${{ steps.detect-package-manager.outputs.manager }}
|
58 |
| - - name: Restore cache |
59 |
| - uses: actions/cache@v3 |
60 |
| - with: |
61 |
| - path: | |
62 |
| - .next/cache |
63 |
| - # Generate a new cache whenever packages or source files change. |
64 |
| - key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} |
65 |
| - # If source files changed but packages didn't, rebuild from a prior cache. |
66 |
| - restore-keys: | |
67 |
| - ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}- |
| 46 | + |
68 | 47 | - name: Install dependencies
|
69 |
| - run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} |
70 |
| - - name: Create Fake Amplify Config |
71 |
| - run: echo "{}" >> amplify_outputs.json |
72 |
| - - name: Build with Next.js |
73 |
| - run: ${{ steps.detect-package-manager.outputs.runner }} next build |
74 |
| - env: |
75 |
| - CONTENTFUL_SPACE_ID: ${{ secrets.CONTENTFUL_SPACE_ID }} |
76 |
| - CONTENTFUL_DELIVERY_API_TOKEN: ${{ secrets.CONTENTFUL_DELIVERY_API_TOKEN }} |
| 48 | + run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.install-command }} |
| 49 | + |
| 50 | + - name: Install ESLint dependencies |
| 51 | + run: | |
| 52 | + ${{ steps.detect-package-manager.outputs.manager }} add [email protected] |
| 53 | + ${{ steps.detect-package-manager.outputs.manager }} add @microsoft/[email protected] |
| 54 | +
|
| 55 | + - name: Run ESLint |
| 56 | + run: | |
| 57 | + ${{ steps.detect-package-manager.outputs.runner }} eslint . |
| 58 | + --config .eslintrc.cjs |
| 59 | + --ext .js,.jsx,.ts,.tsx |
| 60 | + # --format @microsoft/eslint-formatter-sarif |
| 61 | + # --output-file eslint-results.sarif |
| 62 | + |
| 63 | + # Uncomment the following step to upload SARIF results |
| 64 | + # - name: Upload analysis results to GitHub |
| 65 | + # uses: github/codeql-action/upload-sarif@v2 |
| 66 | + # with: |
| 67 | + # sarif_file: eslint-results.sarif |
| 68 | + # wait-for-processing: true |
0 commit comments