100 lines
2.8 KiB
YAML
100 lines
2.8 KiB
YAML
name: Deploy Navigation Site
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
workflow_dispatch:
|
|
|
|
# 设置GITHUB_TOKEN的权限
|
|
permissions:
|
|
contents: write
|
|
pages: write
|
|
id-token: write
|
|
issues: write
|
|
actions: 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 -> Actions -> General
|
|
- 在 "Workflow permissions" 部分
|
|
- 选择 "Read and write permissions"
|
|
- 勾选 "Allow GitHub Actions to create and approve pull requests"
|
|
- 点击 Save
|
|
|
|
2. 然后配置 Pages:
|
|
- 进入仓库的 Settings -> Pages
|
|
- 在 "Build and deployment" 部分
|
|
- Source: 选择 "GitHub Actions"
|
|
- 点击 Save
|
|
|
|
完成以上步骤后,工作流将自动部署您的网站。
|
|
部署完成后,您可以在 Settings -> Pages 中找到您的网站地址。
|
|
|
|
如果遇到权限相关错误,请确保完成了步骤1的所有配置。
|
|
`;
|
|
|
|
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 |