|
3 | 3 | push: |
4 | 4 | branches: |
5 | 5 | - main |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + |
6 | 10 | permissions: |
7 | 11 | contents: write |
| 12 | + |
8 | 13 | jobs: |
| 14 | + test: |
| 15 | + name: Test MkDocs Build |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Setup Python |
| 22 | + uses: actions/setup-python@v4 |
| 23 | + with: |
| 24 | + python-version: 3.x |
| 25 | + |
| 26 | + - name: Cache dependencies |
| 27 | + uses: actions/cache@v3 |
| 28 | + with: |
| 29 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} |
| 30 | + path: ~/.cache/pip |
| 31 | + restore-keys: | |
| 32 | + ${{ runner.os }}-pip- |
| 33 | +
|
| 34 | + - name: Install dependencies |
| 35 | + run: | |
| 36 | + pip install jieba mkdocs-material mkdocs-static-i18n |
| 37 | + |
| 38 | + - name: Build the site for testing |
| 39 | + run: mkdocs build --strict |
| 40 | + |
9 | 41 | deploy: |
| 42 | + name: Deploy to GitHub Pages |
| 43 | + needs: test |
10 | 44 | runs-on: ubuntu-latest |
| 45 | + |
| 46 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 47 | + |
11 | 48 | steps: |
12 | | - - uses: actions/checkout@v4 |
| 49 | + - name: Checkout code |
| 50 | + uses: actions/checkout@v4 |
| 51 | + |
13 | 52 | - name: Configure Git Credentials |
14 | 53 | run: | |
15 | 54 | git config user.name github-actions[bot] |
16 | 55 | git config user.email 41898282+github-actions[bot]@users.noreply.github.com |
17 | | - - uses: actions/setup-python@v4 |
| 56 | +
|
| 57 | + - name: Setup Python |
| 58 | + uses: actions/setup-python@v4 |
18 | 59 | with: |
19 | 60 | python-version: 3.x |
20 | | - - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV |
21 | | - - uses: actions/cache@v3 |
| 61 | + |
| 62 | + - name: Cache dependencies |
| 63 | + uses: actions/cache@v3 |
22 | 64 | with: |
23 | | - key: mkdocs-material-${{ env.cache_id }} |
24 | | - path: .cache |
| 65 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} |
| 66 | + path: ~/.cache/pip |
25 | 67 | restore-keys: | |
26 | | - mkdocs-material- |
27 | | - - run: pip install jieba |
28 | | - - run: pip install mkdocs-material |
29 | | - - run: pip install mkdocs-static-i18n |
30 | | - - run: mkdocs gh-deploy --force |
| 68 | + ${{ runner.os }}-pip- |
| 69 | +
|
| 70 | + - name: Install dependencies |
| 71 | + run: | |
| 72 | + pip install jieba mkdocs-material mkdocs-static-i18n |
| 73 | +
|
| 74 | + - name: Deploy to gh-pages |
| 75 | + run: mkdocs gh-deploy --force |
0 commit comments