Skip to content

Commit 84f4c1e

Browse files
authored
Update nextjs.yml for yarn/npm
1 parent 1e6cdd1 commit 84f4c1e

File tree

1 file changed

+40
-48
lines changed

1 file changed

+40
-48
lines changed

.github/workflows/nextjs.yml

+40-48
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,68 @@
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
62

73
on:
8-
# Runs on pushes targeting the default branch
94
push:
105
branches: ["main"]
11-
126
pull_request:
137
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"
2810

2911
jobs:
30-
# Build job
31-
build:
12+
eslint:
13+
name: Run ESLint Scanning
3214
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
security-events: write
18+
actions: read
3319
steps:
34-
- name: Checkout
35-
uses: actions/checkout@v4
20+
- name: Checkout code
21+
uses: actions/checkout@v3
22+
3623
- name: Detect package manager
3724
id: detect-package-manager
3825
run: |
3926
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
4027
echo "manager=yarn" >> $GITHUB_OUTPUT
41-
echo "command=install" >> $GITHUB_OUTPUT
28+
echo "install-command=install" >> $GITHUB_OUTPUT
4229
echo "runner=yarn" >> $GITHUB_OUTPUT
4330
exit 0
44-
elif [ -f "${{ github.workspace }}/package.json" ]; then
31+
elif [ -f "${{ github.workspace }}/package-lock.json" ]; then
4532
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
4835
exit 0
4936
else
5037
echo "Unable to determine package manager"
5138
exit 1
5239
fi
53-
- name: Setup Node
40+
41+
- name: Setup Node.js
5442
uses: actions/setup-node@v4
5543
with:
5644
node-version: "20"
5745
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+
6847
- 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

Comments
 (0)