From 9a3ca3153ce8280fc8ef9dc8d6c95db68e1e68ad Mon Sep 17 00:00:00 2001 From: Alan Chang Date: Mon, 1 Apr 2024 03:17:23 -0700 Subject: [PATCH] Add new deploy workflow for gh-pages --- .github/workflows/deploy.yml | 51 ++++++++++++++++++++ .github/workflows/setup-node-pnpm/action.yml | 31 ++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/setup-node-pnpm/action.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..be4433c --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,51 @@ +name: deploy-to-github-pages +on: + push: + branches: + - main + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: setup node/pnpm and install dependencies + uses: ./.github/workflows/setup-node-pnpm + + - name: setup pages + uses: actions/configure-pages@v4 + with: + static_site_generator: next + + - name: build nextjs + run: npx next build + + - name: upload + uses: actions/upload-pages-artifact@v3 + with: + path: ./out + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + needs: build + + steps: + - name: publish to github pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/setup-node-pnpm/action.yml b/.github/workflows/setup-node-pnpm/action.yml new file mode 100644 index 0000000..b67dad0 --- /dev/null +++ b/.github/workflows/setup-node-pnpm/action.yml @@ -0,0 +1,31 @@ +name: setup-node-pnpm +description: "Setup node.js & install/cache dependencies with pnpm" +runs: + using: composite + + steps: + - name: setup node + uses: actions/setup-node@v4 + with: + node-version: lts + + - name: setup pnpm + uses: pnpm/action-setup@v3 + with: + version: 8 + run_install: false + + - name: get pnpm store dir + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: cache dependencies in pnpm + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: install dependencies in pnpm + run: pnpm install