|
| 1 | +name: Generate Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [ main ] |
| 6 | + repository_dispatch: |
| 7 | + types: [ generate ] |
| 8 | + workflow_dispatch: |
| 9 | + schedule: |
| 10 | + - cron: '15 5 * * *' |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + # Only run scheduled workflows on the main repository; prevents people |
| 18 | + # from using build minutes on their forks. |
| 19 | + if: github.repository == 'libgit2/www.libgit2.org-docs' |
| 20 | + name: "Generate documentation" |
| 21 | + runs-on: "ubuntu-latest" |
| 22 | + steps: |
| 23 | + - name: Check out repository |
| 24 | + uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + path: docs |
| 27 | + fetch-depth: 0 |
| 28 | + - name: Generate documentation |
| 29 | + run: | |
| 30 | + npm install |
| 31 | + ./generate .. |
| 32 | + working-directory: docs/_generator |
| 33 | + - name: Examine repository |
| 34 | + run: | |
| 35 | + if [ -n "$(git diff --name-only)" ]; then |
| 36 | + echo "changes=true" >> $GITHUB_OUTPUT |
| 37 | + else |
| 38 | + echo "changes=false" >> $GITHUB_OUTPUT |
| 39 | + fi |
| 40 | + id: check |
| 41 | + working-directory: docs |
| 42 | + - name: TODO remove |
| 43 | + run: |
| 44 | + echo ${{ steps.check.outputs.changes }} |
| 45 | + - name: TODO remove |
| 46 | + run: |
| 47 | + echo ${{ steps.check.outputs.changes }} |
| 48 | + if: steps.check.outputs.changes == true |
| 49 | + - name: TODO remove |
| 50 | + run: |
| 51 | + echo ${{ steps.check.outputs.changes }} |
| 52 | + if: steps.check.outputs.changes == "true" |
| 53 | + - name: Publish documentation |
| 54 | + run: |
| 55 | + DATE=$(date +"%Y-%m-%d") |
| 56 | + |
| 57 | + git config user.name 'Documentation Site Generator' |
| 58 | + git config user.email '[email protected]' |
| 59 | + git add . |
| 60 | + git commit -m"Documentation update ${DATE}" |
| 61 | + git push origin main |
| 62 | + if: steps.check.outputs.changes == true |
| 63 | + working-directory: docs |
0 commit comments