|
| 1 | +name: Generate Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '*' |
| 7 | + - '!documentation' |
| 8 | + paths: |
| 9 | + - '.github/workflows/documentation.yml' |
| 10 | + - 'LICENSE' |
| 11 | + |
| 12 | +jobs: |
| 13 | + docs: |
| 14 | + name: "Generate Documentation" |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: "Set up Git" |
| 18 | + shell: bash |
| 19 | + run: | |
| 20 | + git config --global user.name 'GitHub Actions' |
| 21 | + git config --global user.email 'xaymar@users.noreply.github.com' |
| 22 | + git config --global pull.ff only |
| 23 | + git config --global pull.rebase true |
| 24 | +
|
| 25 | + - name: "Clone" |
| 26 | + uses: actions/checkout@v3 |
| 27 | + with: |
| 28 | + submodules: 'recursive' |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: "Clone Documentation" |
| 32 | + uses: actions/checkout@v3 |
| 33 | + with: |
| 34 | + ref: 'documentation' |
| 35 | + path: 'build/docs/html' |
| 36 | + submodules: 'recursive' |
| 37 | + fetch-depth: 0 |
| 38 | + |
| 39 | + - name: "Install Prerequisites" |
| 40 | + shell: bash |
| 41 | + run: | |
| 42 | + sudo apt-get install -y clang-19 clang-tools-19 doxygen graphviz |
| 43 | +
|
| 44 | + - name: "Generate Documentation" |
| 45 | + shell: bash |
| 46 | + run: | |
| 47 | + doxygen Doxyfile |
| 48 | +
|
| 49 | + - name: "Update Documentation" |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + pushd build/docs/html |
| 53 | + git add . |
| 54 | + git --no-pager diff --patch --minimal HEAD -- |
| 55 | + git update-index --refresh |
| 56 | + if ! git diff-index --quiet HEAD --; then |
| 57 | + git commit -a -m "${{ github.sha }}" |
| 58 | +
|
| 59 | + # Only push from master branch. |
| 60 | + if [[ "${{ github.ref }}" == "refs/heads/master" ]]; then |
| 61 | + git push |
| 62 | + echo "Documentation has been updated!" |
| 63 | + else |
| 64 | + git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit |
| 65 | + fi |
| 66 | + else |
| 67 | + echo "Documentation is still up to date." |
| 68 | + fi |
| 69 | + popd |
| 70 | +
|
0 commit comments