Skip to content

Commit 7ff1251

Browse files
Create nextjs_new.yml
1 parent 37103d9 commit 7ff1251

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

.github/workflows/nextjs_new.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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: Deploy Next.js site to Pages
6+
7+
on:
8+
# Runs on pushes targeting the default branch
9+
push:
10+
branches: ["main"]
11+
12+
# Allows you to run this workflow manually from the Actions tab
13+
workflow_dispatch:
14+
15+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
16+
permissions:
17+
contents: read
18+
pages: write
19+
id-token: write
20+
21+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
22+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
23+
concurrency:
24+
group: "pages"
25+
cancel-in-progress: false
26+
27+
jobs:
28+
# Build job
29+
build:
30+
runs-on: ubuntu-latest
31+
defaults:
32+
run:
33+
working-directory: ./tensorsofthewall
34+
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
- name: Detect package manager
39+
id: detect-package-manager
40+
run: |
41+
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
42+
echo "manager=yarn" >> $GITHUB_OUTPUT
43+
echo "command=install" >> $GITHUB_OUTPUT
44+
echo "runner=yarn" >> $GITHUB_OUTPUT
45+
exit 0
46+
elif [ -f "${{ github.workspace }}/tensorsofthewall/package.json" ]; then
47+
echo "manager=npm" >> $GITHUB_OUTPUT
48+
echo "command=ci" >> $GITHUB_OUTPUT
49+
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
50+
exit 0
51+
else
52+
echo "Unable to determine package manager"
53+
exit 1
54+
fi
55+
- name: Setup Node
56+
uses: actions/setup-node@v4
57+
with:
58+
node-version: "20"
59+
cache: ${{ steps.detect-package-manager.outputs.manager }}
60+
cache-dependency-path: "./tensorsofthewall/package-lock.json"
61+
- name: Setup Pages
62+
uses: actions/configure-pages@v5
63+
with:
64+
# Automatically inject basePath in your Next.js configuration file and disable
65+
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
66+
#
67+
# You may remove this line if you want to manage the configuration yourself.
68+
static_site_generator: next
69+
- name: Restore cache
70+
uses: actions/cache@v4
71+
with:
72+
path: |
73+
.next/cache
74+
# Generate a new cache whenever packages or source files change.
75+
key: ${{ runner.os }}-nextjs-${{ hashFiles('./tensorsofthewall/**/package-lock.json', './tensorsofthewall/**/yarn.lock') }}-${{ hashFiles('**.[jt]s', './tensorsofthewall/**.[jt]sx') }}
76+
# If source files changed but packages didn't, rebuild from a prior cache.
77+
restore-keys: |
78+
${{ runner.os }}-nextjs-${{ hashFiles('./tensorsofthewall/**/package-lock.json', './tensorsofthewall/**/yarn.lock') }}-
79+
- name: Install dependencies
80+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
81+
- name: Build with Next.js
82+
run: ${{ steps.detect-package-manager.outputs.runner }} next build
83+
- name: Upload artifact
84+
uses: actions/upload-pages-artifact@v3
85+
with:
86+
path: ./tensorsofthewall/out
87+
88+
# Deployment job
89+
deploy:
90+
environment:
91+
name: github-pages
92+
url: ${{ steps.deployment.outputs.page_url }}
93+
runs-on: ubuntu-latest
94+
needs: build
95+
steps:
96+
- name: Deploy to GitHub Pages
97+
id: deployment
98+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)