diff --git a/.github/workflows/build_website.yaml b/.github/workflows/build_website.yaml index 847bc0d..8fecde6 100644 --- a/.github/workflows/build_website.yaml +++ b/.github/workflows/build_website.yaml @@ -6,6 +6,10 @@ on: push: branches: - main + pull_request: + branches: + - main + workflow_dispatch: # This job installs dependencies, builds the website and pushes it to `gh-pages` @@ -32,4 +36,15 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./_build + # # set it to a subfolder of the root to keep all PR previews: + # destination_dir: latest # cname: website.com + - if: ${{ github.event_name == 'pull_request' }} + name: Save to gh-pages + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./_build + # # create a version for an PR + # # will be automatically deleted in case the build in on the root + destination_dir: pr-${{ github.event.number }} diff --git a/.github/workflows/pr_context_commenter.yaml b/.github/workflows/pr_context_commenter.yaml new file mode 100644 index 0000000..7b62375 --- /dev/null +++ b/.github/workflows/pr_context_commenter.yaml @@ -0,0 +1,32 @@ +name: Publish Link of website for a Pull Request + +on: + pull_request: + types: [opened, reopened] + +jobs: + add-context: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Add PR Context Comment + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const payload = context.payload; + + // Create detailed comment with PR information from payload + const comment = ` + See the preview of the website at: + - https://${context.repo.owner}.github.io/${context.repo.repo}/pr-${payload.number}/ + + `; + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + });