From 726a5a8fdf2a85bcf26695b6c8858efb7d766d76 Mon Sep 17 00:00:00 2001 From: pure-js <3690368+pure-js@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:10:15 +0400 Subject: [PATCH 1/8] ci(deploy): change github pages config --- .github/workflows/nextjs-deploy.yml | 56 ++++++----------------------- next.config.mjs | 1 + 2 files changed, 11 insertions(+), 46 deletions(-) diff --git a/.github/workflows/nextjs-deploy.yml b/.github/workflows/nextjs-deploy.yml index f908e7c..b582191 100644 --- a/.github/workflows/nextjs-deploy.yml +++ b/.github/workflows/nextjs-deploy.yml @@ -5,9 +5,12 @@ name: Deploy Next.js site to Pages on: - # Runs on pushes targeting the default branch + # Runs on tag pushes targeting the default branch push: - branches: ['main'] + branches: + - 'main' + tags: + - '**' # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -28,39 +31,12 @@ jobs: # Build job build: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18] steps: - name: Checkout uses: actions/checkout@v3 - - name: Detect package manager - id: detect-package-manager - run: | - if [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then - echo "manager=pnpm" >> $GITHUB_OUTPUT - echo "command=install" >> $GITHUB_OUTPUT - echo "runner=pnpm exec" >> $GITHUB_OUTPUT - exit 0 - elif [ -f "${{ github.workspace }}/yarn.lock" ]; then - echo "manager=yarn" >> $GITHUB_OUTPUT - echo "command=install" >> $GITHUB_OUTPUT - echo "runner=yarn" >> $GITHUB_OUTPUT - exit 0 - elif [ -f "${{ github.workspace }}/package-lock.json" ]; then - echo "manager=npm" >> $GITHUB_OUTPUT - echo "command=ci" >> $GITHUB_OUTPUT - echo "runner=npx --no-install" >> $GITHUB_OUTPUT - exit 0 - else - echo "Unable to determine package manager" - exit 1 - fi - - name: Setup Node ${{ matrix.node-version }} - uses: actions/setup-node@v3 + - uses: oven-sh/setup-bun@v1 with: - node-version: ${{ matrix.node-version }} - cache: ${{ steps.detect-package-manager.outputs.manager }} + bun-version: latest - name: Setup Pages uses: actions/configure-pages@v3 with: @@ -69,26 +45,14 @@ jobs: # # You may remove this line if you want to manage the configuration yourself. static_site_generator: next - - name: Restore cache - uses: actions/cache@v3 - with: - path: | - .next/cache - # Generate a new cache whenever packages or source files change. - key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} - # If source files changed but packages didn't, rebuild from a prior cache. - restore-keys: | - ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}- - name: Install dependencies - run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} + run: bun install --frozen-lockfile - name: Build with Next.js - run: ${{ steps.detect-package-manager.outputs.runner }} next build - - name: Static HTML export with Next.js - run: ${{ steps.detect-package-manager.outputs.runner }} next export + run: bun run build - name: Upload artifact uses: actions/upload-pages-artifact@v2 with: - path: ./out + path: ./build # Deployment job deploy: diff --git a/next.config.mjs b/next.config.mjs index ff1fa88..9bcd5ed 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -4,6 +4,7 @@ import { createVanillaExtractPlugin } from '@vanilla-extract/next-plugin'; const withVanillaExtract = createVanillaExtractPlugin(); const nextConfig = { + output: 'export', distDir: 'build', experimental: { typedRoutes: true, From cab8ae6bbfa98482e5c0e76094bf02f7b9f78443 Mon Sep 17 00:00:00 2001 From: pure-js <3690368+pure-js@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:12:02 +0400 Subject: [PATCH 2/8] chore: commit some code --- .github/workflows/nextjs-deploy.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nextjs-deploy.yml b/.github/workflows/nextjs-deploy.yml index b582191..a509873 100644 --- a/.github/workflows/nextjs-deploy.yml +++ b/.github/workflows/nextjs-deploy.yml @@ -7,10 +7,11 @@ name: Deploy Next.js site to Pages on: # Runs on tag pushes targeting the default branch push: - branches: - - 'main' - tags: - - '**' + # TODO: uncomment after check + # branches: + # - 'main' + # tags: + # - '**' # Allows you to run this workflow manually from the Actions tab workflow_dispatch: From ce00e26c8d7b1d2fda3675754e024c76e5a0d655 Mon Sep 17 00:00:00 2001 From: pure-js <3690368+pure-js@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:17:23 +0400 Subject: [PATCH 3/8] ci(lighthouse): change assertions scores --- lighthouserc.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lighthouserc.yml b/lighthouserc.yml index 5f804b7..3a51182 100644 --- a/lighthouserc.yml +++ b/lighthouserc.yml @@ -6,10 +6,10 @@ ci: isSinglePageApplication: true assert: assertions: - 'categories:performance': ['error', { 'minScore': 1 }] + 'categories:performance': ['error', { 'minScore': .96 }] 'categories:accessibility': ['error', { 'minScore': .90 }] 'categories:best-practices': ['error', { 'minScore': .92 }] 'categories:pwa': ['off'] - 'categories:seo': ['error', { 'minScore': .91 }] + 'categories:seo': ['error', { 'minScore': .83 }] upload: target: 'temporary-public-storage' From 4439c2836a2733d9d0e3a652412fe763b56038c8 Mon Sep 17 00:00:00 2001 From: pure-js <3690368+pure-js@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:24:14 +0400 Subject: [PATCH 4/8] ci(deploy): change restore cache section --- .github/workflows/nextjs-deploy.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/nextjs-deploy.yml b/.github/workflows/nextjs-deploy.yml index a509873..dc588e8 100644 --- a/.github/workflows/nextjs-deploy.yml +++ b/.github/workflows/nextjs-deploy.yml @@ -46,6 +46,16 @@ jobs: # # You may remove this line if you want to manage the configuration yourself. static_site_generator: next + - name: Restore cache + uses: actions/cache@v3 + with: + path: | + .next/cache + # Generate a new cache whenever packages or source files change. + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml', '**/bun.lockb') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} + # If source files changed but packages didn't, rebuild from a prior cache. + restore-keys: | + ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml', '**/bun.lockb') }}- - name: Install dependencies run: bun install --frozen-lockfile - name: Build with Next.js From 71ab3646ab854950a71038cd80d1dd4522a0d60e Mon Sep 17 00:00:00 2001 From: pure-js <3690368+pure-js@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:34:12 +0400 Subject: [PATCH 5/8] ci(deploy): fix config --- .github/workflows/nextjs-deploy.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nextjs-deploy.yml b/.github/workflows/nextjs-deploy.yml index dc588e8..59cb8e7 100644 --- a/.github/workflows/nextjs-deploy.yml +++ b/.github/workflows/nextjs-deploy.yml @@ -59,7 +59,9 @@ jobs: - name: Install dependencies run: bun install --frozen-lockfile - name: Build with Next.js - run: bun run build + run: bunx next build + - name: Static HTML export with Next.js + run: bunx next export - name: Upload artifact uses: actions/upload-pages-artifact@v2 with: From 99fc9fe991f371366f62d16bb482ef2cc3cf171a Mon Sep 17 00:00:00 2001 From: pure-js <3690368+pure-js@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:51:22 +0400 Subject: [PATCH 6/8] chore: remove deprecated line since v13.30 --- .github/workflows/nextjs-deploy.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/nextjs-deploy.yml b/.github/workflows/nextjs-deploy.yml index 59cb8e7..fec58fd 100644 --- a/.github/workflows/nextjs-deploy.yml +++ b/.github/workflows/nextjs-deploy.yml @@ -60,8 +60,6 @@ jobs: run: bun install --frozen-lockfile - name: Build with Next.js run: bunx next build - - name: Static HTML export with Next.js - run: bunx next export - name: Upload artifact uses: actions/upload-pages-artifact@v2 with: From 97b47fc01a58e2560aa2ee3dd6d238300a031e41 Mon Sep 17 00:00:00 2001 From: pure-js <3690368+pure-js@users.noreply.github.com> Date: Tue, 19 Sep 2023 19:09:26 +0400 Subject: [PATCH 7/8] ci: add new deploy config --- .github/workflows/deploy.yml | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..6069960 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,46 @@ +name: Deploy Next.js static site to GitHub Pages + +on: push + +concurrency: + group: 'pages' + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + - name: Install dependencies + run: bun install --frozen-lockfile + - name: Build + run: bun run build + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 + with: + path: ./build + + deploy: + # Add a dependency to the build job + needs: build + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github-pages environment + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + # Specify runner + deployment step + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 # or the latest "vX.X.X" version tag for this action From ac0e8e5c9603c5e9c7abfff04677bd46a7b156d7 Mon Sep 17 00:00:00 2001 From: pure-js <3690368+pure-js@users.noreply.github.com> Date: Tue, 19 Sep 2023 19:17:42 +0400 Subject: [PATCH 8/8] ci: commit deprecated workflow --- .github/workflows/deploy.yml | 9 +- .github/workflows/nextjs-deploy.yml | 144 ++++++++++++++-------------- 2 files changed, 80 insertions(+), 73 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6069960..a5c6528 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,6 +1,13 @@ name: Deploy Next.js static site to GitHub Pages -on: push +on: + push: + branches: + - 'main' + tags: + - '**' + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: concurrency: group: 'pages' diff --git a/.github/workflows/nextjs-deploy.yml b/.github/workflows/nextjs-deploy.yml index fec58fd..61d29f2 100644 --- a/.github/workflows/nextjs-deploy.yml +++ b/.github/workflows/nextjs-deploy.yml @@ -1,78 +1,78 @@ -# Sample workflow for building and deploying a Next.js site to GitHub Pages -# -# To get started with Next.js see: https://nextjs.org/docs/getting-started -# -name: Deploy Next.js site to Pages +# # Sample workflow for building and deploying a Next.js site to GitHub Pages +# # +# # To get started with Next.js see: https://nextjs.org/docs/getting-started +# # +# name: Deploy Next.js site to Pages -on: - # Runs on tag pushes targeting the default branch - push: - # TODO: uncomment after check - # branches: - # - 'main' - # tags: - # - '**' +# on: +# # Runs on tag pushes targeting the default branch +# push: +# # TODO: uncomment after check +# # branches: +# # - 'main' +# # tags: +# # - '**' - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: +# # Allows you to run this workflow manually from the Actions tab +# workflow_dispatch: -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write +# # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +# permissions: +# contents: read +# pages: write +# id-token: write -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. -concurrency: - group: 'pages' - cancel-in-progress: false +# # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +# concurrency: +# group: 'pages' +# cancel-in-progress: false -jobs: - # Build job - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - uses: oven-sh/setup-bun@v1 - with: - bun-version: latest - - name: Setup Pages - uses: actions/configure-pages@v3 - with: - # Automatically inject basePath in your Next.js configuration file and disable - # server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized). - # - # You may remove this line if you want to manage the configuration yourself. - static_site_generator: next - - name: Restore cache - uses: actions/cache@v3 - with: - path: | - .next/cache - # Generate a new cache whenever packages or source files change. - key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml', '**/bun.lockb') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} - # If source files changed but packages didn't, rebuild from a prior cache. - restore-keys: | - ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml', '**/bun.lockb') }}- - - name: Install dependencies - run: bun install --frozen-lockfile - - name: Build with Next.js - run: bunx next build - - name: Upload artifact - uses: actions/upload-pages-artifact@v2 - with: - path: ./build +# jobs: +# # Build job +# build: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout +# uses: actions/checkout@v3 +# - uses: oven-sh/setup-bun@v1 +# with: +# bun-version: latest +# - name: Setup Pages +# uses: actions/configure-pages@v3 +# with: +# # Automatically inject basePath in your Next.js configuration file and disable +# # server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized). +# # +# # You may remove this line if you want to manage the configuration yourself. +# static_site_generator: next +# - name: Restore cache +# uses: actions/cache@v3 +# with: +# path: | +# .next/cache +# # Generate a new cache whenever packages or source files change. +# key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml', '**/bun.lockb') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} +# # If source files changed but packages didn't, rebuild from a prior cache. +# restore-keys: | +# ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml', '**/bun.lockb') }}- +# - name: Install dependencies +# run: bun install --frozen-lockfile +# - name: Build with Next.js +# run: bunx next build +# - name: Upload artifact +# uses: actions/upload-pages-artifact@v2 +# with: +# path: ./build - # Deployment job - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v2 +# # Deployment job +# deploy: +# environment: +# name: github-pages +# url: ${{ steps.deployment.outputs.page_url }} +# runs-on: ubuntu-latest +# needs: build +# steps: +# - name: Deploy to GitHub Pages +# id: deployment +# uses: actions/deploy-pages@v2