|
| 1 | +# This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | +# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | +# file, You can obtain one at https://mozilla.org/MPL/2.0/. |
| 4 | + |
| 5 | +name: Compile + Sync Docs |
| 6 | + |
| 7 | +on: |
| 8 | + pull_request: |
| 9 | + types: |
| 10 | + - opened |
| 11 | + - reopened |
| 12 | + - closed |
| 13 | + - synchronize |
| 14 | + |
| 15 | + push: |
| 16 | + branches: |
| 17 | + - master |
| 18 | + |
| 19 | + |
| 20 | +jobs: |
| 21 | + notify-docs: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: "Checkout" |
| 25 | + if: github.event_name == 'pull_request' && github.event.action != 'closed' |
| 26 | + uses: actions/checkout@v3 |
| 27 | + |
| 28 | + # This is just a sanity check to make sure that the follow-up docs generation doesn't break. |
| 29 | + # So we use the Rust version provided by the GitHub runners, which hopefully is >= MSRV. |
| 30 | + - name: "Compile" |
| 31 | + if: github.event_name == 'pull_request' && github.event.action != 'closed' |
| 32 | + run: cargo check -p godot $GDEXT_FEATURES |
| 33 | + |
| 34 | + # Pushed to master: no PR-related information |
| 35 | + - name: "Construct JSON (for master)" |
| 36 | + if: github.ref == 'refs/heads/master' |
| 37 | + run: | |
| 38 | + payload=$(cat <<'HEREDOC' |
| 39 | + { |
| 40 | + "op": "put", |
| 41 | + "repo": "gdext", |
| 42 | + "num": "master", |
| 43 | + "commit-sha": "${{ github.sha }}", |
| 44 | + "date": "${{ github.event.head_commit.timestamp }}" |
| 45 | + } |
| 46 | + HEREDOC) |
| 47 | + echo "VAR=$payload" |
| 48 | + echo "GDEXT_JSON<<HEREDOC" >> $GITHUB_ENV |
| 49 | + echo "${payload}" >> $GITHUB_ENV |
| 50 | + echo "HEREDOC" >> $GITHUB_ENV |
| 51 | +
|
| 52 | + # Opened/reopened/updated PR: include PR author + title |
| 53 | + - name: "Construct JSON (for PR sync)" |
| 54 | + if: github.event_name == 'pull_request' && github.event.action != 'closed' |
| 55 | + run: | |
| 56 | + payload=$(cat <<'HEREDOC' |
| 57 | + { |
| 58 | + "op": "put", |
| 59 | + "repo": "gdext", |
| 60 | + "num": "${{ github.event.number }}", |
| 61 | + "commit-sha": "${{ github.event.pull_request.head.sha }}", |
| 62 | + "date": "${{ github.event.pull_request.updated_at }}", |
| 63 | + "pr-author": "${{ github.event.pull_request.user.login }}", |
| 64 | + "pr-title": "${{ github.event.pull_request.title }}" |
| 65 | + } |
| 66 | + HEREDOC) |
| 67 | + echo "VAR=$payload" |
| 68 | + echo "GDEXT_JSON<<HEREDOC" >> $GITHUB_ENV |
| 69 | + echo "${payload}" >> $GITHUB_ENV |
| 70 | + echo "HEREDOC" >> $GITHUB_ENV |
| 71 | +
|
| 72 | + # Closed/merged PR: no more PR-related information necessary, as it will be removed |
| 73 | + - name: "Construct JSON (for closed PR)" |
| 74 | + if: github.event_name == 'pull_request' && github.event.action == 'closed' |
| 75 | + run: | |
| 76 | + payload=$(cat <<'HEREDOC' |
| 77 | + { |
| 78 | + "op": "delete", |
| 79 | + "repo": "gdext", |
| 80 | + "num": "${{ github.event.number }}", |
| 81 | + "date": "${{ github.event.pull_request.updated_at }}" |
| 82 | + } |
| 83 | + HEREDOC) |
| 84 | + echo "VAR=$payload" |
| 85 | + echo "GDEXT_JSON<<HEREDOC" >> $GITHUB_ENV |
| 86 | + echo "${payload}" >> $GITHUB_ENV |
| 87 | + echo "HEREDOC" >> $GITHUB_ENV |
| 88 | +
|
| 89 | + - name: "Print payload" |
| 90 | + run: | |
| 91 | + echo "$GDEXT_JSON" |
| 92 | +
|
| 93 | + - name: "Prepare request" |
| 94 | + run: | |
| 95 | + token=$(cat .github/external-config/public-docs-token.txt | base64 -w0 -d) |
| 96 | + echo "DOCS_GENERATOR_TOKEN=github_pat_$token" >> $GITHUB_ENV |
| 97 | +
|
| 98 | + - name: "Notify doc workflow" |
| 99 | + uses: peter-evans/repository-dispatch@v2 |
| 100 | + with: |
| 101 | + token: ${{ env.DOCS_GENERATOR_TOKEN }} |
| 102 | + repository: godot-rust/dispatch-forwarder |
| 103 | + event-type: 'Generate docs' |
| 104 | + client-payload: ${{ env.GDEXT_JSON }} |
| 105 | + |
0 commit comments