fix(api): add CORS headers and OPTIONS handler for preflight requests #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| CI: true | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Lint | |
| run: pnpm lint | |
| - name: Chinese Text Lint (zhlint) | |
| run: pnpm lint:zh | |
| continue-on-error: true | |
| build: | |
| needs: lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: pnpm | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Cache pnpm store | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Cache VitePress | |
| uses: actions/cache@v4 | |
| with: | |
| path: .vitepress/cache | |
| key: ${{ runner.os }}-vitepress-${{ hashFiles('**/*.md') }} | |
| restore-keys: | | |
| ${{ runner.os }}-vitepress- | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build | |
| run: pnpm build | |
| env: | |
| VITEPRESS_BASE: /halolight/ | |
| - name: Deploy to halolight/halolight gh-pages | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| personal_token: ${{ secrets.DEPLOY_TOKEN }} | |
| external_repository: halolight/halolight | |
| publish_branch: gh-pages | |
| publish_dir: .vitepress/dist | |
| force_orphan: true | |
| - name: Output deployment URL | |
| run: | | |
| echo "::notice::Deployed to https://halolight.docs.h7ml.cn/" | |
| echo "## Deployment Complete" >> $GITHUB_STEP_SUMMARY | |
| echo "Site deployed to: https://halolight.docs.h7ml.cn/" >> $GITHUB_STEP_SUMMARY |