Create documentation workflow #10
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: Generate Documentation | |
on: | |
pull_request: | |
branches: [ main ] | |
repository_dispatch: | |
types: [ generate ] | |
workflow_dispatch: | |
schedule: | |
- cron: '15 5 * * *' | |
permissions: | |
contents: write | |
jobs: | |
build: | |
# Only run scheduled workflows on the main repository; prevents people | |
# from using build minutes on their forks. | |
if: github.repository == 'libgit2/www.libgit2.org-docs' | |
name: "Generate documentation" | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
with: | |
path: docs | |
fetch-depth: 0 | |
- name: Generate documentation | |
run: | | |
npm install | |
./generate .. | |
working-directory: docs/_generator | |
- name: Examine repository | |
run: | | |
if [ -n "$(git diff --name-only)" ]; then | |
echo "changes=true" >> $GITHUB_OUTPUT | |
else | |
echo "changes=false" >> $GITHUB_OUTPUT | |
fi | |
id: check | |
working-directory: docs | |
- name: TODO remove | |
run: | |
echo ${{ steps.check.outputs.changes }} | |
- name: TODO remove | |
run: | |
echo ${{ steps.check.outputs.changes }} | |
if: steps.check.outputs.changes == true | |
- name: TODO remove | |
run: | |
echo ${{ steps.check.outputs.changes }} | |
if: steps.check.outputs.changes == 'true' | |
- name: Publish documentation | |
run: | |
DATE=$(date +"%Y-%m-%d") | |
git config user.name 'Documentation Site Generator' | |
git config user.email '[email protected]' | |
git add . | |
git commit -m"Documentation update ${DATE}" | |
git push origin main | |
if: steps.check.outputs.changes == 'true' | |
working-directory: docs |