|
| 1 | +name: Build developer docs |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [main] |
| 5 | + pull_request: |
| 6 | + branches: [main, release-next] |
| 7 | + |
| 8 | +# cancel previous job if new commit is pushed |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +jobs: |
| 14 | + devsite: |
| 15 | + if: ${{ github.repository_owner == 'mantidproject' }} |
| 16 | + runs-on: ubuntu-latest |
| 17 | + defaults: |
| 18 | + run: |
| 19 | + shell: bash -l {0} |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout Mantid source |
| 23 | + uses: actions/checkout@v6 |
| 24 | + |
| 25 | + - name: Detect changes relevant to developer site |
| 26 | + uses: dorny/paths-filter@v4 |
| 27 | + id: changes |
| 28 | + with: |
| 29 | + filters: .github/filters.yaml |
| 30 | + |
| 31 | + - name: Read pixi version |
| 32 | + id: pixi-version |
| 33 | + run: echo "version=$(tr -d '[:space:]' < .pixi-version)" >> "$GITHUB_OUTPUT" |
| 34 | + |
| 35 | + - name: Setup pixi |
| 36 | + if: steps.changes.outputs.devsite == 'true' |
| 37 | + uses: prefix-dev/setup-pixi@v0.9.5 |
| 38 | + with: |
| 39 | + pixi-version: v${{ steps.pixi-version.outputs.version }} |
| 40 | + frozen: true |
| 41 | + |
| 42 | + - name: Build dev-docs |
| 43 | + if: steps.changes.outputs.devsite == 'true' |
| 44 | + run: pixi run --manifest-path pixi.toml build-devdocs |
| 45 | + |
| 46 | + - name: Checkout developer site repository |
| 47 | + if: ${{ steps.changes.outputs.devsite == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' }} |
| 48 | + uses: actions/checkout@v6 |
| 49 | + with: |
| 50 | + repository: mantidproject/developer |
| 51 | + ref: gh-pages |
| 52 | + path: developer_repo |
| 53 | + token: ${{ secrets.DEVELOPER_REPO_TOKEN }} |
| 54 | + |
| 55 | + - name: Copy generated site |
| 56 | + if: ${{ steps.changes.outputs.devsite == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' }} |
| 57 | + run: | |
| 58 | + rm -rf developer_repo/* |
| 59 | + cp -r build_devsite_html/* developer_repo/ |
| 60 | +
|
| 61 | + # publish devsite to mantidproject/developer repo when merged to main branch |
| 62 | + - name: Publish developer site |
| 63 | + if: ${{ steps.changes.outputs.devsite == 'true' && github.event_name == 'push' && github.ref == 'refs/heads/main' }} |
| 64 | + working-directory: developer_repo |
| 65 | + run: | |
| 66 | + git config user.name "github-actions[bot]" |
| 67 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 68 | + git add . |
| 69 | + git diff --cached --quiet && echo "No changes to commit" && exit 0 |
| 70 | + git commit -m "Automatic update of developer site from ${{ github.sha }}" |
| 71 | + git push origin gh-pages |
0 commit comments