Skip to content

Update deploy.yml to configure Git identity for GitHub Actions #5

Update deploy.yml to configure Git identity for GitHub Actions

Update deploy.yml to configure Git identity for GitHub Actions #5

Workflow file for this run

name: Deploy Docusaurus to GitHub Pages
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false # Ensure the token is not persisted in the git config
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Build Docusaurus site
run: npm run build
- name: Clean gh-pages branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git fetch origin
git checkout gh-pages || git checkout --orphan gh-pages
git rm -rf .
git clean -fdx
git commit --allow-empty -m "Clean gh-pages branch"
git push origin gh-pages
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
destination_dir: swdr5-docs