Skip to content

Commit

Permalink
chore: migrate to spa
Browse files Browse the repository at this point in the history
  • Loading branch information
nekomeowww committed Dec 3, 2024
1 parent 83fb9b5 commit cd0f371
Show file tree
Hide file tree
Showing 81 changed files with 4,434 additions and 2,825 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build Previewing Docs

on:
pull_request:
branches:
- main

env:
STORE_PATH: ''

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]

name: Build - ${{ matrix.os }}

runs-on: ${{ matrix.os }}
steps:
# This is quite weird.
# Eventhough this is the *intended* solution introduces in official blog post here
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/.
# But still, as https://github.com/orgs/community/discussions/25220#discussioncomment-7856118 stated,
# this is vulnerable since there is no source of truth about which PR in the triggered workflow.
- name: Presist PR number
run: |
echo "${{ github.event.number }}" > pr_num
- name: Upload PR artifact
uses: actions/upload-artifact@v4
with:
name: pr-num
path: ./pr_num
overwrite: true

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build packages
run: pnpm packages:build
env:
# As suggested in Verbose Build option to be able to track down errors https://github.com/vuejs/vitepress/issues/422
# vitepress build command does not have --debug option, so we need to set it manually where the debug package is used.
DEBUG: none

- name: Build docs
run: pnpm docs:build
env:
# As suggested in Verbose Build option to be able to track down errors https://github.com/vuejs/vitepress/issues/422
# vitepress build command does not have --debug option, so we need to set it manually where the debug package is used.
# DEBUG: 'vitepress:*'
VUE_PROD_HYDRATION_MISMATCH_DETAILS_FLAG: '1'

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: docs-${{ matrix.os }}-build
path: docs/.vitepress/dist
overwrite: true
22 changes: 0 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,3 @@ jobs:

- name: Typecheck
run: pnpm run typecheck

test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [18.x, 20.x]
os: [ubuntu-latest]
fail-fast: false

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/
cache: pnpm

- run: pnpm install
- run: pnpm run test:unit
151 changes: 151 additions & 0 deletions .github/workflows/preview-docs-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: Push Previewing Docs to Netlify

on:
workflow_run:
workflows:
- Build Previewing Docs
types:
- completed

env:
PR_NUM: 0
STORE_PATH: ''
UBUNTU_NETLIFY_JSON_OUTPUT: ''
UBUNTU_NETLIFY_URL: ''
WINDOWS_NETLIFY_JSON_OUTPUT: ''
WINDOWS_NETLIFY_URL: ''

jobs:
on-success:
name: Deploy to Netlify
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download artifact - PR
uses: dawidd6/action-download-artifact@v7
with:
workflow_conclusion: success
run_id: ${{ github.event.workflow_run.id }}
name: pr-num
path: pr-num
allow_forks: true

- name: Obtain PR number
id: pr-num
run: |
echo "PR_NUM=$(cat pr-num/pr_num)" >> $GITHUB_ENV
- name: Download artifact - Ubuntu
uses: dawidd6/action-download-artifact@v7
with:
workflow_conclusion: success
run_id: ${{ github.event.workflow_run.id }}
name: docs-ubuntu-latest-build
path: docs-ubuntu-latest-build
allow_forks: true

- name: Install Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
run_install: false
version: 9

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Netlify CLI
run: pnpm install -g [email protected]

- name: Push to Netlify - Ubuntu
id: netlify-ubuntu-latest
timeout-minutes: 10
run: |
UBUNTU_NETLIFY_JSON_OUTPUT=$(netlify deploy --dir docs-ubuntu-latest-build --json)
echo $UBUNTU_NETLIFY_JSON_OUTPUT
echo "UBUNTU_NETLIFY_JSON_OUTPUT=$(echo $UBUNTU_NETLIFY_JSON_OUTPUT)" >> $GITHUB_ENV
echo "UBUNTU_NETLIFY_URL=$(echo $UBUNTU_NETLIFY_JSON_OUTPUT | jq -r .deploy_url)" >> $GITHUB_ENV
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ env.PR_NUM }}
comment-author: 'github-actions[bot]'
body-includes: to Netlify

- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ env.PR_NUM }}
body: |
## ✅ Successfully deployed to Netlify
| Platform | Status | URL |
|:---------|:------------|:---------------------------------|
| Ubuntu | Success | ${{ env.UBUNTU_NETLIFY_URL }} |
edit-mode: replace

on-failure:
name: Failed to build previewing docs
runs-on: ubuntu-latest
permissions:
pull-requests: write

if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: Download artifact - PR
uses: dawidd6/action-download-artifact@v7
with:
workflow_conclusion: success
run_id: ${{ github.event.workflow_run.id }}
name: pr-num
path: pr-num
allow_forks: true

- name: Obtain PR number
id: pr-num
run: |
echo "PR_NUM=$(cat pr-num/pr_num)" >> $GITHUB_ENV
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ env.PR_NUM }}
comment-author: 'github-actions[bot]'
body-includes: to Netlify

- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ env.PR_NUM }}
body: |
## ❌ Failed to deploy to Netlify
| Platform | Status | URL |
|:---------|:------------|:------------------------------------------------------|
| Ubuntu | Failed | Please check the status and logs of the workflow run. |
edit-mode: replace
70 changes: 70 additions & 0 deletions .github/workflows/production-docs-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Build Docs to Netlify

on:
push:
branches:
- main

env:
STORE_PATH: ''

jobs:
build:
name: Build
runs-on: ubuntu-24.04
environment:
name: Production Docs
url: https://nolebase-integrations.ayaka.io
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x

- uses: pnpm/action-setup@v3
name: Install pnpm
with:
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build docs
run: |
pnpm packages:build
pnpm docs:build
env:
# As suggested in Verbose Build option to be able to track down errors https://github.com/vuejs/vitepress/issues/422
# vitepress build command does not have --debug option, so we need to set it manually where the debug package is used.
# DEBUG: 'vitepress:*'
VUE_PROD_HYDRATION_MISMATCH_DETAILS_FLAG: '1'

- name: Install Netlify CLI
run: pnpm install -g [email protected]

- name: Push to Netlify
timeout-minutes: 10
working-directory: docs/
run: |
netlify deploy --dir 'docs/.vitepress/dist' --prod --debug
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
.vite-inspect
*.local
*.log
.cache/
components.d.ts
dist
node_modules
.eslintcache
.cache/
**/.vitepress/docsMetadata.json
**/.vitepress/cache/

Expand Down
Loading

0 comments on commit cd0f371

Please sign in to comment.