diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 380f6a59f18be..75f2788abda2e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,6 +1,7 @@ name: deploy on: + workflow_dispatch: push: branches: - main @@ -12,22 +13,14 @@ on: - lcof/** - lcci/** - basic/** - workflow_dispatch: - -env: - MKDOCS_API_KEYS: ${{ secrets.MKDOCS_API_KEYS }} - -permissions: - contents: write concurrency: group: ${{github.workflow}} - ${{github.ref}} cancel-in-progress: true jobs: - deploy: + build: runs-on: ubuntu-latest - if: github.repository == 'doocs/leetcode' steps: - uses: actions/checkout@v4 - uses: actions/checkout@v4 @@ -62,36 +55,36 @@ jobs: python3 -m pip install -r requirements.txt python3 -m pip install "mkdocs-material[imaging]" sudo apt-get install pngquant + + - name: Set MKDOCS_API_KEYS environment variable + run: echo "MKDOCS_API_KEYS=${{ secrets.MKDOCS_API_KEYS }}" >> $GITHUB_ENV - run: | python3 main.py mkdocs build -f mkdocs.yml mkdocs build -f mkdocs-en.yml - - name: Deploy - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./site - cname: leetcode.doocs.org + - name: Generate CNAME file + run: echo "leetcode.doocs.org" > ./site/CNAME - # sync: - # runs-on: ubuntu-latest - # needs: deploy - # if: github.repository == 'doocs/leetcode' - # steps: - # - name: Sync to gitee.com - # uses: wearerequired/git-mirror-action@master - # env: - # SSH_PRIVATE_KEY: ${{ secrets.RSA_PRIVATE_KEY }} - # with: - # source-repo: git@github.com:doocs/leetcode.git - # destination-repo: git@gitee.com:Doocs/leetcode.git + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./site - # - name: Build Gitee Pages - # uses: yanglbme/gitee-pages-action@main - # with: - # gitee-username: yanglbme - # gitee-password: ${{ secrets.GITEE_PASSWORD }} - # gitee-repo: doocs/leetcode - # branch: gh-pages + # Deployment job + deploy: + needs: build + permissions: + pages: write + id-token: write + environment: + name: github_pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }}