|
1 | 1 | name: deploy
|
2 | 2 |
|
3 | 3 | on:
|
| 4 | + workflow_dispatch: |
4 | 5 | push:
|
5 | 6 | branches:
|
6 | 7 | - main
|
|
12 | 13 | - lcof/**
|
13 | 14 | - lcci/**
|
14 | 15 | - basic/**
|
15 |
| - workflow_dispatch: |
16 |
| - |
17 |
| -env: |
18 |
| - MKDOCS_API_KEYS: ${{ secrets.MKDOCS_API_KEYS }} |
19 |
| - |
20 |
| -permissions: |
21 |
| - contents: write |
22 | 16 |
|
23 | 17 | concurrency:
|
24 | 18 | group: ${{github.workflow}} - ${{github.ref}}
|
25 | 19 | cancel-in-progress: true
|
26 | 20 |
|
27 | 21 | jobs:
|
28 |
| - deploy: |
| 22 | + build: |
29 | 23 | runs-on: ubuntu-latest
|
30 |
| - if: github.repository == 'doocs/leetcode' |
31 | 24 | steps:
|
32 | 25 | - uses: actions/checkout@v4
|
33 | 26 | - uses: actions/checkout@v4
|
@@ -62,36 +55,36 @@ jobs:
|
62 | 55 | python3 -m pip install -r requirements.txt
|
63 | 56 | python3 -m pip install "mkdocs-material[imaging]"
|
64 | 57 | sudo apt-get install pngquant
|
| 58 | + |
| 59 | + - name: Set MKDOCS_API_KEYS environment variable |
| 60 | + run: echo "MKDOCS_API_KEYS=${{ secrets.MKDOCS_API_KEYS }}" >> $GITHUB_ENV |
65 | 61 |
|
66 | 62 | - run: |
|
67 | 63 | python3 main.py
|
68 | 64 | mkdocs build -f mkdocs.yml
|
69 | 65 | mkdocs build -f mkdocs-en.yml
|
70 | 66 |
|
71 |
| - - name: Deploy |
72 |
| - uses: peaceiris/actions-gh-pages@v4 |
73 |
| - with: |
74 |
| - github_token: ${{ secrets.GITHUB_TOKEN }} |
75 |
| - publish_dir: ./site |
76 |
| - cname: leetcode.doocs.org |
| 67 | + - name: Generate CNAME file |
| 68 | + run: echo "leetcode.doocs.org" > ./site/CNAME |
77 | 69 |
|
78 |
| - # sync: |
79 |
| - # runs-on: ubuntu-latest |
80 |
| - # needs: deploy |
81 |
| - # if: github.repository == 'doocs/leetcode' |
82 |
| - # steps: |
83 |
| - # - name: Sync to gitee.com |
84 |
| - # uses: wearerequired/git-mirror-action@master |
85 |
| - # env: |
86 |
| - # SSH_PRIVATE_KEY: ${{ secrets.RSA_PRIVATE_KEY }} |
87 |
| - # with: |
88 |
| - # source-repo: [email protected]:doocs/leetcode.git |
89 |
| - # destination-repo: [email protected]:Doocs/leetcode.git |
| 70 | + - name: Upload artifact |
| 71 | + uses: actions/upload-pages-artifact@v3 |
| 72 | + with: |
| 73 | + path: ./site |
90 | 74 |
|
91 |
| - # - name: Build Gitee Pages |
92 |
| - # uses: yanglbme/gitee-pages-action@main |
93 |
| - # with: |
94 |
| - # gitee-username: yanglbme |
95 |
| - # gitee-password: ${{ secrets.GITEE_PASSWORD }} |
96 |
| - # gitee-repo: doocs/leetcode |
97 |
| - # branch: gh-pages |
| 75 | + # Deployment job |
| 76 | + deploy: |
| 77 | + needs: build |
| 78 | + permissions: |
| 79 | + pages: write |
| 80 | + id-token: write |
| 81 | + environment: |
| 82 | + name: github_pages |
| 83 | + url: ${{ steps.deployment.outputs.page_url }} |
| 84 | + runs-on: ubuntu-latest |
| 85 | + steps: |
| 86 | + - name: Deploy to GitHub Pages |
| 87 | + id: deployment |
| 88 | + uses: actions/deploy-pages@v4 |
| 89 | + with: |
| 90 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments