| 1 |
# Update the www.libgit2.org reference documentation |
| 2 |
name: Generate Documentation |
| 3 |
|
| 4 |
on: |
| 5 |
push: |
| 6 |
branches: [ main ] |
| 7 |
release: |
| 8 |
workflow_dispatch: |
| 9 |
inputs: |
| 10 |
force: |
| 11 |
description: 'Force rebuild' |
| 12 |
type: boolean |
| 13 |
required: true |
| 14 |
|
| 15 |
concurrency: |
| 16 |
group: documentation |
| 17 |
|
| 18 |
permissions: |
| 19 |
contents: read |
| 20 |
|
| 21 |
jobs: |
| 22 |
documentation: |
| 23 |
name: "Generate documentation" |
| 24 |
runs-on: "ubuntu-latest" |
| 25 |
steps: |
| 26 |
- name: Check out source repository |
| 27 |
uses: actions/checkout@v4 |
| 28 |
with: |
| 29 |
path: source |
| 30 |
fetch-depth: 0 |
| 31 |
- name: Check out documentation repository |
| 32 |
uses: actions/checkout@v4 |
| 33 |
with: |
| 34 |
repository: libgit2/www.libgit2.org |
| 35 |
path: www |
| 36 |
fetch-depth: 0 |
| 37 |
ssh-key: ${{ secrets.DOCS_PUBLISH_KEY }} |
| 38 |
- name: Prepare branches |
| 39 |
run: | |
| 40 |
for a in main $(git branch -r --list 'origin/maint/*' | sed -e "s/^ origin\///"); do |
| 41 |
if [ "$(git rev-parse --abbrev-ref HEAD)" != "${a}" ]; then |
| 42 |
git branch --track "$a" "origin/$a" |
| 43 |
fi |
| 44 |
done |
| 45 |
working-directory: source |
| 46 |
- name: Generate documentation |
| 47 |
run: | |
| 48 |
args="" |
| 49 |
|
| 50 |
if [ "${{ inputs.force }}" = "true" ]; then |
| 51 |
args="--force" |
| 52 |
fi |
| 53 |
|
| 54 |
npm install |
| 55 |
./generate --verbose $args ../.. ../../../www/docs |
| 56 |
working-directory: source/script/api-docs |
| 57 |
- name: Examine changes |
| 58 |
run: | |
| 59 |
if [ -n "$(git diff --name-only)" ]; then |
| 60 |
echo "changes=true" >> $GITHUB_OUTPUT |
| 61 |
else |
| 62 |
echo "changes=false" >> $GITHUB_OUTPUT |
| 63 |
fi |
| 64 |
id: check |
| 65 |
working-directory: www |
| 66 |
- name: Publish documentation |
| 67 |
run: | |
| 68 |
DATE=$(date +"%Y-%m-%d") |
| 69 |
|
| 70 |
git config user.name 'Documentation Site Generator' |
| 71 |
git config user.email '[email protected]' |
| 72 |
git add . |
| 73 |
git commit -m"Documentation update ${DATE}" |
| 74 |
git push origin main |
| 75 |
if: steps.check.outputs.changes == 'true' |
| 76 |
working-directory: www |