|
1 | | -name: Generate API docs and publish to Github Pages |
| 1 | +# TODO: |
| 2 | +# - Theming for Moodle |
| 3 | +# - Document ALL code (below we exclude a bunch to try on a subset) |
| 4 | + |
| 5 | +# Generate API docs and publish to GitHub Pages at phpdoc.moodledev.io |
| 6 | +# |
| 7 | +# How it works: |
| 8 | +# - Get Moodle code into .moodle |
| 9 | +# - Build docs into .docs |
| 10 | +# - Publish that to phpdoc.moodledev.io |
| 11 | + |
| 12 | +name: Generate phpdoc.moodledev.io |
2 | 13 |
|
3 | 14 | env: |
4 | 15 | BRANCHLIST: "MOODLE_401_STABLE MOODLE_402_STABLE MOODLE_403_STABLE main" |
5 | 16 | VERSIONLIST: "4.1 4.2 4.3 main" |
6 | 17 |
|
| 18 | +# Allow GITHUB_TOKEN to deploy to GitHub Pages |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + pages: write |
| 22 | + id-token: write |
| 23 | + |
7 | 24 | on: |
8 | 25 | schedule: |
9 | | - # Publish every Sunday at 1:30am |
| 26 | + # Publish every Sunday at 00:30 UTC |
10 | 27 | - cron: '30 1 * * 0' |
11 | 28 | workflow_dispatch: |
12 | 29 |
|
13 | 30 | jobs: |
14 | | - deploy: |
15 | | - runs-on: ubuntu-20.04 |
| 31 | + build: |
| 32 | + runs-on: ubuntu-latest |
16 | 33 | concurrency: |
17 | 34 | group: ${{ github.workflow }}-${{ github.ref }} |
| 35 | + cancel-in-progress: true |
18 | 36 | steps: |
19 | 37 | - uses: actions/checkout@v4 |
20 | 38 | with: |
21 | 39 | fetch-depth: 0 |
22 | | - show-progress: '' |
| 40 | + show-progress: false |
23 | 41 |
|
24 | 42 | - name: Checkout Moodle |
25 | 43 | uses: actions/checkout@v4 |
26 | 44 | with: |
27 | 45 | repository: moodle/moodle |
28 | 46 | path: .moodle |
29 | | - show-progress: '' |
| 47 | + show-progress: false |
30 | 48 |
|
31 | 49 | - name: Setup Node |
32 | 50 | uses: actions/setup-node@v4 |
33 | 51 | with: |
34 | 52 | node-version-file: '.moodle/.nvmrc' |
35 | 53 |
|
36 | | - - name: Build doxygen |
37 | | - run: docker build --tag=doxygen phpdocs/doxygen |
38 | | - |
39 | | - - name: Generate all API Documentation |
40 | | - run: ./scripts/generate_api_docs.sh |
| 54 | + - name: Cache phpDocumentor build files |
| 55 | + id: phpdocumentor-cache |
| 56 | + uses: actions/cache@v4 |
| 57 | + with: |
| 58 | + path: .phpdoc/cache |
| 59 | + key: ${{ runner.os }}-phpdocumentor-${{ github.sha }} |
| 60 | + restore-keys: | |
| 61 | + ${{ runner.os }}-phpdocumentor- |
41 | 62 |
|
42 | | - - name: Copy Moodle Redirector |
43 | | - run: | |
44 | | - mkdir -p build/master |
45 | | - cp redirect.html build/master/index.html |
| 63 | + # TODO: remove the ignores below, they speed up the runs for quick evaluation while we're setting this up |
| 64 | + - name: Build with phpDocumentor |
| 65 | + run: docker run --rm --volume "$(pwd):/data" phpdoc/phpdoc:3 -vv -d .moodle --target .docs --cache-folder .phpdoc/cache --template default --ignore .moodle/libs --ignore .moodle/admin --ignore .moodle/mod --ignore .moodle/blocks |
46 | 66 |
|
47 | | - - name: Deploy |
48 | | - uses: peaceiris/actions-gh-pages@v3 |
| 67 | + - name: Upload artifact to GitHub Pages |
| 68 | + uses: actions/upload-pages-artifact@v3 |
49 | 69 | with: |
50 | | - github_token: ${{ secrets.GITHUB_TOKEN }} |
51 | | - publish_dir: ./build |
52 | | - cname: phpdoc.moodledev.io |
| 70 | + path: .docs |
53 | 71 |
|
54 | | - - name: Archive build ogs |
55 | | - if: always() |
56 | | - uses: actions/upload-artifact@v4 |
57 | | - with: |
58 | | - name: Build logs |
59 | | - path: logs |
| 72 | + deploy: |
| 73 | + needs: build |
| 74 | + |
| 75 | + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment |
| 76 | + permissions: |
| 77 | + pages: write # to deploy to Pages |
| 78 | + id-token: write # to verify the deployment originates from an appropriate source |
| 79 | + |
| 80 | + # Deploy to the github-pages environment |
| 81 | + environment: |
| 82 | + name: github-pages |
| 83 | + url: ${{ steps.deployment.outputs.page_url }} |
| 84 | + |
| 85 | + runs-on: ubuntu-latest |
| 86 | + steps: |
| 87 | + - name: Deploy to GitHub Pages |
| 88 | + id: deployment |
| 89 | + uses: actions/deploy-pages@v4 |
0 commit comments