Update and Build LeetCode Site #247
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update and Build LeetCode Site | |
| on: | |
| workflow_dispatch: | |
| workflow_run: | |
| workflows: ["Update LeetCode Grid"] | |
| types: | |
| - completed | |
| concurrency: | |
| group: ${{ github.workflow }} - ${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| update-readmes: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.x | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pyyaml requests | |
| - name: Restore LeetCode API cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: .leetcode_cache.json | |
| key: leetcode-cache-latest | |
| restore-keys: | | |
| leetcode-cache- | |
| - name: Update READMEs | |
| run: python ./Scripts/update_readmes.py | |
| - name: Upload docs and mkdocs.yml as artifact | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: mkdocs-docs | |
| path: | | |
| docs | |
| mkdocs.yml | |
| Style | |
| Site_README.md | |
| build-site: | |
| runs-on: ubuntu-latest | |
| needs: update-readmes | |
| steps: | |
| - name: Download docs artifact | |
| uses: actions/download-artifact@v6 | |
| with: | |
| name: mkdocs-docs | |
| path: . | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.x | |
| - name: Install MkDocs | |
| run: pip install mkdocs mkdocs-material mkdocs-awesome-pages-plugin pymdown-extensions mkdocs-material[imaging] mkdocs-glightbox | |
| - name: Prepare docs folder | |
| run: | | |
| cp Style/overrides.css docs/ | |
| echo "leetcode.romitsagu.com" > ./docs/CNAME | |
| cp Site_README.md docs/README.md | |
| - name: Build site | |
| run: mkdocs build --clean --site-dir site | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: ./site | |
| deploy: | |
| needs: build-site | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |