|
| 1 | +name: github pages |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main # deploy main. If your branch is `master`, you'll have to replace that throughout this file. |
| 7 | + pull_request: # This will publish a site preview on every pull request, and also run the build command to test if the site is broken. |
| 8 | + |
| 9 | +jobs: |
| 10 | + deploy: |
| 11 | + runs-on: ubuntu-22.04 |
| 12 | + env: |
| 13 | + PR_PATH: pull/${{github.event.number}} |
| 14 | + steps: |
| 15 | + - name: Comment on PR |
| 16 | + |
| 17 | + if: github.ref != 'refs/heads/main' |
| 18 | + with: |
| 19 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 20 | + repository: ${{ github.repository }} |
| 21 | + number: ${{ github.event.number }} |
| 22 | + id: deploy-preview |
| 23 | + message: "Starting deployment of preview ⏳..." |
| 24 | + |
| 25 | + - name: Set domain |
| 26 | + run: echo "DOMAIN=lip6.github.io" >> $GITHUB_ENV # TODO set your custom domain |
| 27 | + # If you're using the default github pages url, use this instead: |
| 28 | + # run: echo "DOMAIN=${{ github.actor }}.github.io" >> $GITHUB_ENV |
| 29 | + |
| 30 | + - name: Checkout website repo |
| 31 | + uses: actions/checkout@v2 |
| 32 | + with: |
| 33 | + submodules: true # fetch the theme |
| 34 | + # you need to set this as an environment env if your repo or any submodules (e.g the theme) is private: |
| 35 | + # token: ${{ secrets.PRIVATE_REPO_TOKEN }} |
| 36 | + |
| 37 | + - name: Set production base URL |
| 38 | + run: echo "BASE_URL=https://${{ env.DOMAIN }}/${{ github.event.repository.name }}/" >> $GITHUB_ENV |
| 39 | + |
| 40 | + - name: Setup PDM |
| 41 | + uses: pdm-project/setup-pdm@v3 |
| 42 | + |
| 43 | + - name: Build website |
| 44 | + run: | |
| 45 | + sudo apt install -y graphviz doxygen doxygen-latex python3-docutils qtbase5-dev libqt5svg5-dev |
| 46 | + pdm sync -d --no-self |
| 47 | + pdm run meson setup --prefix=/home/runner/work/install -D docs=true -D only-docs=true -D docs-siteurl=$BASE_URL builddir |
| 48 | + pdm run meson install -C builddir |
| 49 | +
|
| 50 | + - name: Deploy if this is the `main` branch |
| 51 | + uses: peaceiris/actions-gh-pages@v3 |
| 52 | + if: github.ref == 'refs/heads/main' |
| 53 | + with: |
| 54 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + publish_dir: /home/runner/work/install/share/doc/html |
| 56 | + cname: ${{ env.DOMAIN }} # TODO you need to set this if you're using a custom domain. Otherwise you can remove it. |
| 57 | + |
| 58 | + - name: Set base URL for preview if PR |
| 59 | + if: github.ref != 'refs/heads/main' |
| 60 | + run: echo "BASE_URL=https://${{ env.DOMAIN }}/${{ github.event.repository.name }}/${{ env.PR_PATH}}/" >> $GITHUB_ENV |
| 61 | + |
| 62 | + - name: Build PR preview website |
| 63 | + if: github.ref != 'refs/heads/main' |
| 64 | + run: | |
| 65 | + pdm run meson setup -D docs=true -D docs-siteurl=$BASE_URL builddir |
| 66 | + pdm run meson install -C builddir |
| 67 | +
|
| 68 | + - name: Deploy to PR preview |
| 69 | + uses: peaceiris/actions-gh-pages@v3 |
| 70 | + if: github.ref != 'refs/heads/main' |
| 71 | + with: |
| 72 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + publish_dir: /home/runner/work/install/share/doc/html |
| 74 | + destination_dir: ${{ env.PR_PATH }} # TODO you need to set this if you're using a custom domain. Otherwise you can remove it. |
| 75 | + |
| 76 | + - name: Update comment |
| 77 | + |
| 78 | + if: github.ref != 'refs/heads/main' |
| 79 | + with: |
| 80 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 81 | + repository: ${{ github.repository }} |
| 82 | + number: ${{ github.event.number }} |
| 83 | + id: deploy-preview |
| 84 | + message: "A preview of ${{ github.event.after }} is uploaded and can be seen here:\n\n ✨ ${{ env.BASE_URL }} ✨\n\nChanges may take a few minutes to propagate. Since this is a preview of production, content with `draft: true` will not be rendered. The source is here: https://github.com/${{ github.repository }}/tree/gh-pages/${{ env.PR_PATH }}/" |
0 commit comments