diff options
Diffstat (limited to '.github/workflows')
| -rw-r--r-- | .github/workflows/mkdocs-deploy.yml | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/.github/workflows/mkdocs-deploy.yml b/.github/workflows/mkdocs-deploy.yml index f20ef3d..e77f6fb 100644 --- a/.github/workflows/mkdocs-deploy.yml +++ b/.github/workflows/mkdocs-deploy.yml @@ -1,4 +1,4 @@ -name: Deploy MkDocs to GitHub +name: Deploy MkDocs to Another Repository on: push: @@ -13,8 +13,6 @@ on: permissions: contents: read - pages: write - id-token: write concurrency: group: "pages" @@ -23,36 +21,39 @@ concurrency: jobs: build-and-deploy: runs-on: ubuntu-latest - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} steps: - - name: Checkout 源码 + - name: Checkout source code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: 设置 Python 环境 + - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.13' cache: 'pip' - - name: 安装 MkDocs 及依赖 + - name: Install MkDocs dependencies run: | python -m pip install --upgrade pip pip install -r requirements.txt - - name: 构建 MkDocs 站点 + - name: Build MkDocs site run: mkdocs build --strict env: DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} - - name: Setup Pages - uses: actions/configure-pages@v5 - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - path: ./site - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v5 + + - name: Deploy to target repository + env: + TARGET_REPO: https://github.com/LinuxCabin/handbook-site + TARGET_BRANCH: gh-pages + # 个人访问令牌(需要有写入目标仓库的权限) + DEPLOY_TOKEN: ${{ secrets.DEPLOY_KEY }} + run: | + cd site + git init + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Deploy site $(date -u '+%Y-%m-%d %H:%M:%S UTC')" + git push --force https://x-access-token:${DEPLOY_TOKEN}@${TARGET_REPO#https://} HEAD:${TARGET_BRANCH}
\ No newline at end of file |
