diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6f828c6..dfdd4a9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,52 +7,46 @@ on: # 添加fork后的首次运行触发 fork: +# 设置GITHUB_TOKEN的权限 +permissions: + contents: read + pages: write + id-token: write + +# 允许一个并发部署 +concurrency: + group: "pages" + cancel-in-progress: true + jobs: - build-and-deploy: + build: runs-on: ubuntu-latest - permissions: - contents: write - pages: write - id-token: write - steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Check GitHub Pages status - id: pages-status - run: | - if [ "$(gh api repos/${{ github.repository }}/pages --jq .status)" != "null" ]; then - echo "GitHub Pages is already enabled" - echo "pages_enabled=true" >> $GITHUB_OUTPUT - else - echo "GitHub Pages needs to be enabled manually" - echo "pages_enabled=false" >> $GITHUB_OUTPUT - fi - env: - GH_TOKEN: ${{ github.token }} - - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '16' + cache: 'npm' - name: Install dependencies - run: npm install + run: npm ci - name: Generate site - run: node generator.js + run: npm run generate - - name: Deploy to GitHub Pages - if: steps.pages-status.outputs.pages_enabled == 'true' - uses: JamesIves/github-pages-deploy-action@v4 + - name: Setup Pages + uses: actions/configure-pages@v3 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 with: - folder: . - branch: gh-pages - clean: true + path: '.' - name: Create deployment guide issue - if: steps.pages-status.outputs.pages_enabled == 'false' + if: github.event_name == 'fork' uses: actions/github-script@v6 with: script: | @@ -76,4 +70,15 @@ jobs: title: '🚀 如何部署您的导航站点', body: issueBody, labels: ['documentation'] - }); \ No newline at end of file + }); + + 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@v2 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3b7bdf1..5a2e1e1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,11 +3,6 @@ node_modules/ npm-debug.log* yarn-debug.log* yarn-error.log* -package-lock.json - -# 构建产物 -public/ -index.html # IDE 配置 .vscode/ diff --git a/CHANGELOG.md b/CHANGELOG.md index d7ea3c5..82d21c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,4 +49,18 @@ ### 新增 - 项目初始化 - 基础文件结构 -- 开发环境配置 \ No newline at end of file +- 开发环境配置 + +## [1.2.3] - 2024-03-21 + +### 优化 +- 改进GitHub Pages部署流程 + - 使用官方推荐的部署方式 + - 添加自动化部署配置 + - 优化构建缓存 +- 更新依赖管理 + - 添加开发服务器支持 + - 优化依赖版本控制 +- 改进项目配置 + - 优化.gitignore规则 + - 添加homepage配置 \ No newline at end of file diff --git a/package.json b/package.json index 31efe98..43d9030 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,13 @@ { "name": "menav", - "version": "1.0.0", + "version": "1.2.3", "description": "A personal navigation website", "main": "generator.js", + "homepage": "https://RZLNB.github.io/menav", "scripts": { - "generate": "node generator.js" + "generate": "node generator.js", + "dev": "node generator.js && serve .", + "clean": "rm -rf index.html" }, "keywords": [ "navigation", @@ -15,5 +18,8 @@ "license": "MIT", "dependencies": { "js-yaml": "^4.1.0" + }, + "devDependencies": { + "serve": "^14.2.1" } } \ No newline at end of file