Files
menav/.github/workflows/deploy.yml
2025-02-02 21:02:13 +08:00

88 lines
2.3 KiB
YAML

name: Deploy Navigation Site
on:
push:
branches: [ main ]
workflow_dispatch:
# 设置GITHUB_TOKEN的权限
permissions:
contents: read
pages: write
id-token: write
# 允许一个并发部署
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
build:
# 只在原仓库或fork的仓库中运行
if: github.repository == 'RZLNB/menav' || github.event.repository.fork == true
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '16'
cache: 'npm'
- name: Clean install
run: |
rm -rf node_modules
rm -f package-lock.json
npm install
- name: Generate site
run: npm run generate
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: '.'
- name: Create deployment guide issue
# 只在fork的仓库中创建issue
if: github.event.repository.fork == true
uses: actions/github-script@v7
with:
script: |
const issueBody = `
# 部署指南
请按照以下简单步骤完成网站部署:
1. 进入仓库设置 Settings -> Pages
2. 在 "Source" 下拉菜单中选择 "GitHub Actions"
3. 点击 Save
完成后,工作流将自动部署您的导航站点。
部署完成后,您可以在 Settings -> Pages 中找到您的网站地址。
`;
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '🚀 如何部署您的导航站点',
body: issueBody,
labels: ['documentation']
});
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@v4