From 5e1e89af14b1fdd555580790983d83c189abe797 Mon Sep 17 00:00:00 2001 From: Tadashi Shigeoka Date: Fri, 18 Aug 2023 23:02:46 +0900 Subject: [PATCH 1/5] [DNM] Deploy to GitHub Pages on every push --- .github/workflows/nextjs.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/nextjs.yml b/.github/workflows/nextjs.yml index d5886ae..d353975 100644 --- a/.github/workflows/nextjs.yml +++ b/.github/workflows/nextjs.yml @@ -7,7 +7,6 @@ name: Deploy Next.js site to Pages on: # Runs on pushes targeting the default branch push: - branches: ["main"] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: From 1f4d4311a81cd703a431a634be08a44749a54aa5 Mon Sep 17 00:00:00 2001 From: Tadashi Shigeoka Date: Fri, 18 Aug 2023 23:04:11 +0900 Subject: [PATCH 2/5] [DNM] fix assetPrefix --- next.config.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/next.config.js b/next.config.js index ab728a0..a683e7c 100644 --- a/next.config.js +++ b/next.config.js @@ -1,8 +1,9 @@ /** * @type {import('next').NextConfig} */ -const isProd = process.env.NODE_ENV === 'production' +// const isProd = process.env.NODE_ENV === 'production' module.exports = { - assetPrefix: isProd ? '/nextjs-blog-starter-sandbox' : undefined, + // assetPrefix: isProd ? '/nextjs-blog-starter-sandbox' : undefined, + assetPrefix: '/nextjs-blog-starter-sandbox', } From 748ba748be1e80dc4704edcf9582583c4c79e231 Mon Sep 17 00:00:00 2001 From: Tadashi Shigeoka Date: Fri, 18 Aug 2023 23:21:42 +0900 Subject: [PATCH 3/5] [DNM] fix dead link using CoverImage component on GitHub Pages --- components/cover-image.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/cover-image.tsx b/components/cover-image.tsx index 4c200c5..ee33513 100644 --- a/components/cover-image.tsx +++ b/components/cover-image.tsx @@ -11,7 +11,7 @@ type Props = { const CoverImage = ({ title, src, slug }: Props) => { const image = ( {`Cover Date: Fri, 18 Aug 2023 23:32:25 +0900 Subject: [PATCH 4/5] [DNM] Assign process.env.ASSET_PREFIX in GitHub Actions --- .github/workflows/nextjs.yml | 4 ++-- components/avatar.tsx | 2 +- components/cover-image.tsx | 2 +- next.config.js | 5 +---- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/nextjs.yml b/.github/workflows/nextjs.yml index d353975..994c965 100644 --- a/.github/workflows/nextjs.yml +++ b/.github/workflows/nextjs.yml @@ -74,11 +74,11 @@ jobs: - name: Build with Next.js run: ${{ steps.detect-package-manager.outputs.runner }} next build env: - NODE_ENV: production + ASSET_PREFIX: /nextjs-blog-starter-sandbox - name: Static HTML export with Next.js run: ${{ steps.detect-package-manager.outputs.runner }} next export env: - NODE_ENV: production + ASSET_PREFIX: /nextjs-blog-starter-sandbox - name: Upload artifact uses: actions/upload-pages-artifact@v1 with: diff --git a/components/avatar.tsx b/components/avatar.tsx index 920d385..22f186e 100644 --- a/components/avatar.tsx +++ b/components/avatar.tsx @@ -6,7 +6,7 @@ type Props = { const Avatar = ({ name, picture }: Props) => { return (
- {name} + {name}
{name}
) diff --git a/components/cover-image.tsx b/components/cover-image.tsx index ee33513..ccf6d6f 100644 --- a/components/cover-image.tsx +++ b/components/cover-image.tsx @@ -11,7 +11,7 @@ type Props = { const CoverImage = ({ title, src, slug }: Props) => { const image = ( {`Cover Date: Fri, 18 Aug 2023 23:41:30 +0900 Subject: [PATCH 5/5] [DNM] refactor: Get github repository name in GitHub Actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ref - [リポジトリ名の取得 \[GitHub Actions\]](https://zenn.dev/snowcait/articles/757d0c6815227f) --- .github/workflows/nextjs.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nextjs.yml b/.github/workflows/nextjs.yml index 994c965..5138ce1 100644 --- a/.github/workflows/nextjs.yml +++ b/.github/workflows/nextjs.yml @@ -29,6 +29,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + - name: Get github repository name + id: github-repository + run: echo "name=${GITHUB_REPOSITORY#${GITHUB_REPOSITORY_OWNER}/}" >> $GITHUB_OUTPUT - name: Detect package manager id: detect-package-manager run: | @@ -74,11 +77,11 @@ jobs: - name: Build with Next.js run: ${{ steps.detect-package-manager.outputs.runner }} next build env: - ASSET_PREFIX: /nextjs-blog-starter-sandbox + ASSET_PREFIX: /${{ steps.github-repository.outputs.name }} - name: Static HTML export with Next.js run: ${{ steps.detect-package-manager.outputs.runner }} next export env: - ASSET_PREFIX: /nextjs-blog-starter-sandbox + ASSET_PREFIX: /${{ steps.github-repository.outputs.name }} - name: Upload artifact uses: actions/upload-pages-artifact@v1 with: