|
| 1 | +name: Build and Deploy Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + tags: |
| 7 | + - 'v[0-9]*.[0-9]*.[0-9]*' |
| 8 | + pull_request: |
| 9 | + types: [opened, synchronize, reopened] |
| 10 | + |
| 11 | +jobs: |
| 12 | + Build_and_deploy_doc: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: write |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Setup PDM |
| 21 | + uses: pdm-project/setup-pdm@v4 |
| 22 | + with: |
| 23 | + python-version: '3.13' |
| 24 | + |
| 25 | + - name: Install dependencies (default & doc) |
| 26 | + run: pdm install --group doc --frozen-lockfile |
| 27 | + |
| 28 | + - name: Build Documentation |
| 29 | + working-directory: docs |
| 30 | + run: pdm run make dirhtml |
| 31 | + |
| 32 | + - name: Determine deployment folder |
| 33 | + id: deploy_folder |
| 34 | + run: | |
| 35 | + echo "Determining deployment folder..." |
| 36 | + if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 37 | + echo "Deploying to target pr/${{ github.event.number }}" |
| 38 | + echo "DEPLOY_DIR=pr/${{ github.event.number }}" >> $GITHUB_OUTPUT |
| 39 | + elif [[ "${{ github.ref }}" == refs/tags/* ]]; then |
| 40 | + echo "Deploying to target ${{ github.ref_name }}" |
| 41 | + echo "DEPLOY_DIR=${{ github.ref_name }}" >> $GITHUB_OUTPUT |
| 42 | + else |
| 43 | + echo "Deploying to target main" |
| 44 | + echo "DEPLOY_DIR=main" >> $GITHUB_OUTPUT |
| 45 | + fi |
| 46 | +
|
| 47 | + - name: Deploy to DEPLOY_DIR of TorchJD/documentation |
| 48 | + uses: peaceiris/actions-gh-pages@v4 |
| 49 | + with: |
| 50 | + deploy_key: ${{ secrets.DOCUMENTATION_DEPLOY_KEY }} |
| 51 | + publish_dir: docs/build/dirhtml |
| 52 | + destination_dir: ${{ steps.deploy_folder.outputs.DEPLOY_DIR }} |
| 53 | + external_repository: TorchJD/documentation |
| 54 | + publish_branch: main |
| 55 | + |
| 56 | + - name: Deploy to stable of TorchJD/documentation |
| 57 | + if: startsWith(github.ref, 'refs/tags/') |
| 58 | + uses: peaceiris/actions-gh-pages@v4 |
| 59 | + with: |
| 60 | + deploy_key: ${{ secrets.DOCUMENTATION_DEPLOY_KEY }} |
| 61 | + publish_dir: docs/build/dirhtml |
| 62 | + destination_dir: stable |
| 63 | + external_repository: TorchJD/documentation |
| 64 | + publish_branch: main |
| 65 | + |
| 66 | + - name: Add documentation link to summary |
| 67 | + run: | |
| 68 | + echo "### 📄 [View Deployed Documentation](https://torchjd.github.io/documentation/${{ steps.deploy_folder.outputs.DEPLOY_DIR }})" >> $GITHUB_STEP_SUMMARY |
0 commit comments