aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/mkdocs-deploy.yml
blob: 9a96a0db899793f44b512bc5c9eb7d89c02bf79c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Deploy MkDocs to Another Repository

on:
  push:
    branches:
      - main
    paths:
      - 'docs/**'
      - 'mkdocs.yml'
      - 'overrides/**'
      - '.github/workflows/mkdocs-deploy.yml'
  workflow_dispatch:

permissions:
  contents: read

concurrency:
  group: "pages"
  cancel-in-progress: false

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout source code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.13'
          cache: 'pip'

      - name: Install MkDocs dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt

      - name: Build MkDocs site
        run: mkdocs build --strict
        env:
          DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}

      - name: Deploy to target repository
        env:
          TARGET_REPO: https://github.com/LinuxCabin/handbook-site
          TARGET_BRANCH: gh-pages
          DEPLOY_TOKEN: ${{ secrets.DEPLOY_KEY }}
          CUSTOM_DOMAIN: hb.linuxcabin.top
        run: |
          cd site
          echo "${{ env.CUSTOM_DOMAIN }}" > CNAME
          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}