Skip to content

Commit 970416a

Browse files
committed
feature: GH Actions Base Path Env Var
1 parent 9b993f0 commit 970416a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.github/workflows/deploy.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ on:
1515
# Allows you to run this workflow manually from the Actions tab
1616
workflow_dispatch:
1717

18+
env:
19+
NEXT_PUBLIC_BASE_PATH: ${{ vars.NEXT_PUBLIC_BASE_PATH }}
20+
1821
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1922
permissions:
2023
contents: read
@@ -76,9 +79,14 @@ jobs:
7679
- name: Install dependencies
7780
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
7881

79-
- name: Build with Next.js
82+
- name: Build with Next.js (No base path)
83+
if: ${{ env.NEXT_PUBLIC_BASE_PATH == '' }}
8084
run: ${{ steps.detect-package-manager.outputs.runner }} next build
8185

86+
- name: Build with Next.js (With base path)
87+
if: ${{ env.NEXT_PUBLIC_BASE_PATH != '' }}
88+
run: NEXT_PUBLIC_BASE_PATH=${{ env.NEXT_PUBLIC_BASE_PATH }} ${{ steps.detect-package-manager.outputs.runner }} next build
89+
8290
- name: Add .nojekyll to out directory
8391
run: touch out/.nojekyll
8492

next.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
reactStrictMode: true,
33
output: 'export',
4-
basePath: "",
4+
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "",
55
images: {
66
unoptimized: true,
77
},

0 commit comments

Comments
 (0)