mirror of
https://github.com/libgit2/libgit2.git
synced 2026-01-25 02:56:17 +00:00
Don't build docs on pushes to maint branches; those docs should only be built _on release_. In addition, be safer about not creating an existing branch from a tracking branch.
77 lines
2.0 KiB
YAML
77 lines
2.0 KiB
YAML
# Update the www.libgit2.org reference documentation
|
|
name: Generate Documentation
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
release:
|
|
workflow_dispatch:
|
|
inputs:
|
|
force:
|
|
description: 'Force rebuild'
|
|
type: boolean
|
|
required: true
|
|
|
|
concurrency:
|
|
group: documentation
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
documentation:
|
|
name: "Generate documentation"
|
|
runs-on: "ubuntu-latest"
|
|
steps:
|
|
- name: Check out source repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
path: source
|
|
fetch-depth: 0
|
|
- name: Check out documentation repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: libgit2/www.libgit2.org
|
|
path: www
|
|
fetch-depth: 0
|
|
ssh-key: ${{ secrets.DOCS_PUBLISH_KEY }}
|
|
- name: Prepare branches
|
|
run: |
|
|
for a in main $(git branch -r --list 'origin/maint/*' | sed -e "s/^ origin\///"); do
|
|
if [ "$(git rev-parse --abbrev-ref HEAD)" != "${a}" ]; then
|
|
git branch --track "$a" "origin/$a"
|
|
fi
|
|
done
|
|
working-directory: source
|
|
- name: Generate documentation
|
|
run: |
|
|
args=""
|
|
|
|
if [ "${{ inputs.force }}" = "true" ]; then
|
|
args="--force"
|
|
fi
|
|
|
|
npm install
|
|
./generate --verbose $args ../.. ../../../www/docs
|
|
working-directory: source/script/api-docs
|
|
- name: Examine changes
|
|
run: |
|
|
if [ -n "$(git diff --name-only)" ]; then
|
|
echo "changes=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "changes=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
id: check
|
|
working-directory: www
|
|
- name: Publish documentation
|
|
run: |
|
|
DATE=$(date +"%Y-%m-%d")
|
|
|
|
git config user.name 'Documentation Site Generator'
|
|
git config user.email 'libgit2@users.noreply.github.com'
|
|
git add .
|
|
git commit -m"Documentation update ${DATE}"
|
|
git push origin main
|
|
if: steps.check.outputs.changes == 'true'
|
|
working-directory: www
|