添加根目录 404 页面 #30
This file contains 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: PageForge CI | |
on: | |
push: | |
branches: [ dev ] | |
pull_request: | |
branches: [ dev ] | |
jobs: | |
test-command: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16.x, 18.x, 20.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Get pnpm store directory | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- uses: actions/cache@v3 | |
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 | |
- name: Link package globally | |
run: | | |
pnpm link --global | |
pnpm link --global pageforge | |
- name: Run linting | |
run: pnpm run lint || echo "No lint script found" | |
- name: Run unit tests | |
run: pnpm test || echo "No test script found" | |
- name: Test create-site command | |
run: | | |
mkdir -p test-sites | |
pageforge create-site test-sites/site1 | |
- name: Test init command | |
run: | | |
mkdir -p test-sites/site2 | |
cd test-sites/site2 | |
pageforge init | |
- name: Test build command | |
run: | | |
mkdir -p test-sites/site3 | |
cd test-sites/site3 | |
pageforge create-site . | |
pageforge build | |
- name: Test serve command | |
run: | | |
mkdir -p test-sites/site4 | |
cd test-sites/site4 | |
pageforge create-site . | |
pageforge build | |
timeout 30s pageforge serve --port 3001 & | |
sleep 5 | |
curl -f http://localhost:3001 | |
- name: Build project | |
run: pnpm run build || echo "No build script found" | |
test-deploy: | |
needs: test-command | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Install dependencies | |
run: pnpm install | |
- name: Link package globally | |
run: | | |
pnpm link --global | |
pnpm link --global pageforge | |
- name: Test deploy-github command | |
run: | | |
mkdir -p test-sites/site4 | |
cd test-sites/site4 | |
pageforge create-site . | |
pageforge build | |
git config --global user.email "[email protected]" | |
git config --global user.name "Test User" | |
git init | |
git add . | |
git commit -m "Initial commit" | |
pageforge deploy-github || echo "Deploy failed as expected in test environment" |