ci: only update docs on main branch #177
This file contains 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: Documentation Generator | |
on: | |
push: | |
branches: | |
- "main" | |
jobs: | |
docs: | |
name: Documentation | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v3 | |
with: | |
version: latest | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "pnpm" | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Checkout docs branch | |
uses: actions/checkout@v4 | |
with: | |
repository: distubejs/distubejs.github.io | |
ref: gh-pages | |
path: gh-pages | |
token: ${{ secrets.DISTUBE_TOKEN }} | |
- name: Delete old docs | |
run: find gh-pages -mindepth 1 ! -regex 'gh-pages/\.git.*' ! -name 'CNAME' -exec rm -rf {} + | |
- name: Generate documentation | |
run: pnpm run docs | |
- name: Commit and push | |
run: | | |
rsync -av docs/ gh-pages/ | |
cd gh-pages | |
git config user.name github-actions[bot] | |
git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
git add . | |
git commit -m "${{ github.repository }}@${{ github.sha }} 🚀" | |
git push |