trigger-update-docs #208
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: Update Docs | |
on: | |
repository_dispatch: | |
types: [trigger-update-docs] | |
workflow_dispatch: {} | |
jobs: | |
update_docs: | |
name: Update Docs and Push a Commit | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
- name: Clone the Pluto main repository | |
run: git clone https://github.com/pluto-lang/pluto.git | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Update docs | |
run: pnpm run update-docs | |
- name: Remove the directory of the Pluto repository | |
run: rm -rf pluto | |
- name: Exit if no updates | |
# `git diff-index --quiet HEAD --` will return a 1 if there are any updates. | |
run: | | |
if git diff --quiet && [ -z "$(git status --porcelain)" ]; then | |
echo "No updates in documentation." | |
echo "NO_UPDATE=true" >> $GITHUB_ENV | |
else | |
git diff --name-only | |
fi | |
- name: Commit changes | |
if: env.NO_UPDATE != 'true' | |
run: | | |
git config --global user.name 'GitHub Actions' | |
git config --global user.email '[email protected]' | |
git add . | |
git commit -m "feat(docs): update docs" -m "Updates the docs. See details in [workflow run]. | |
[Workflow Run]: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
------ | |
*Automatically created via the 'update-docs' workflow*" | |
- name: Push changes | |
if: env.NO_UPDATE != 'true' | |
run: git push origin main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |