|
1 | 1 | # https://squidfunk.github.io/mkdocs-material/publishing-your-site/ |
2 | 2 | name: ci |
3 | 3 | on: |
4 | | - push: |
5 | | - branches: |
6 | | - - master |
7 | | - - main |
8 | | - workflow_dispatch: |
9 | | - |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + workflow_dispatch: |
| 11 | + |
10 | 12 | permissions: |
11 | | - contents: write |
| 13 | + contents: write |
12 | 14 | jobs: |
13 | | - deploy: |
14 | | - runs-on: ubuntu-latest |
15 | | - steps: |
16 | | - - uses: actions/checkout@v4 |
17 | | - with: |
18 | | - fetch-depth: 0 |
19 | | - - name: sed mkdocs.yaml |
20 | | - run: | |
21 | | - sed -i 's/enabled: false/enabled: true/' mkdocs.yml |
22 | | - - name: Configure Git Credentials |
23 | | - run: | |
24 | | - git config user.name github-actions[bot] |
25 | | - git config user.email 41898282+github-actions[bot]@users.noreply.github.com |
26 | | - - uses: actions/setup-python@v5 |
27 | | - with: |
28 | | - python-version: 3.x |
29 | | - - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV |
30 | | - - uses: actions/cache@v4 |
31 | | - with: |
32 | | - key: mkdocs-material-${{ env.cache_id }} |
33 | | - path: .cache |
34 | | - restore-keys: | |
35 | | - mkdocs-material- |
36 | | - - run: pip install -r requirements.txt |
37 | | - - run: mkslides build slides/ -d site-slides |
38 | | - - run: mv site-slides/index.html docs/slides/index.md |
39 | | - - run: mkdocs build |
40 | | - - run: mv site-slides/* site/slides/ |
41 | | - - run: rm -rf site/slides/assets/reveal-js/.git |
42 | | - - run: mkdocs gh-deploy --dirty --force --no-history |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + - uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: 3.x |
| 24 | + - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV |
| 25 | + - uses: actions/cache@v4 |
| 26 | + with: |
| 27 | + key: mkdocs-material-${{ env.cache_id }} |
| 28 | + path: .cache |
| 29 | + restore-keys: | |
| 30 | + mkdocs-material- |
| 31 | + - run: pip install -r requirements.txt |
| 32 | + - run: mkslides build slides/ -d site-slides |
| 33 | + - run: mv site-slides/index.html docs/slides/index.md |
| 34 | + - run: mkdocs build |
| 35 | + |
| 36 | + deploy: |
| 37 | + # only deploy on main repo |
| 38 | + runs-on: ubuntu-latest |
| 39 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'ZJUSCT/HPC101' |
| 40 | + needs: build |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + fetch-depth: 0 |
| 45 | + - name: enable git-committers |
| 46 | + run: | |
| 47 | + sed -i 's/enabled: false/enabled: true/' mkdocs.yml |
| 48 | + - name: Configure Git Credentials |
| 49 | + run: | |
| 50 | + git config user.name github-actions[bot] |
| 51 | + git config user.email 41898282+github-actions[bot]@users.noreply.github.com |
| 52 | + - uses: actions/setup-python@v5 |
| 53 | + with: |
| 54 | + python-version: 3.x |
| 55 | + - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV |
| 56 | + - uses: actions/cache@v4 |
| 57 | + with: |
| 58 | + key: mkdocs-material-${{ env.cache_id }} |
| 59 | + path: .cache |
| 60 | + restore-keys: | |
| 61 | + mkdocs-material- |
| 62 | + - run: pip install -r requirements.txt |
| 63 | + - run: mkslides build slides/ -d site-slides |
| 64 | + - run: mv site-slides/index.html docs/slides/index.md |
| 65 | + - run: mkdocs build |
| 66 | + - run: mv site-slides/* site/slides/ |
| 67 | + - run: rm -rf site/slides/assets/reveal-js/.git |
| 68 | + - run: mkdocs gh-deploy --dirty --force --no-history |
0 commit comments