From c55ee27d580307d479ad6241fa29828347761a4b Mon Sep 17 00:00:00 2001 From: Henry Webel Date: Tue, 23 Sep 2025 14:46:27 +0200 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=9A=A7=20add=20PR=20preview=20for=20w?= =?UTF-8?q?ebsites?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build_website.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 }} From fc1fe2fbbcdc7640bfd96d3cba655205481075b6 Mon Sep 17 00:00:00 2001 From: Henry Webel Date: Tue, 23 Sep 2025 15:18:46 +0200 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=9A=A7=20play=20with=20automations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr_context_commenter.yaml | 39 +++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/pr_context_commenter.yaml diff --git a/.github/workflows/pr_context_commenter.yaml b/.github/workflows/pr_context_commenter.yaml new file mode 100644 index 0000000..94fb087 --- /dev/null +++ b/.github/workflows/pr_context_commenter.yaml @@ -0,0 +1,39 @@ +name: PR Context Commenter + +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://enryh.github.io/notes_template/pr-${payload.number}/ + + - Repository: ${context.repo.repo} + - {context.repo.repo} + + ### Basic Information + - PR Number: #${payload.number} + + ### Author Information + - Author: @${payload.pull_request.user.login} + `; + + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }); From 5577b10020bb7b7569946ae60ff764592793af95 Mon Sep 17 00:00:00 2001 From: Henry Webel Date: Tue, 23 Sep 2025 15:23:35 +0200 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=9A=A7=20try=20to=20add=20url=20based?= =?UTF-8?q?=20on=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/pr_context_commenter.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr_context_commenter.yaml b/.github/workflows/pr_context_commenter.yaml index 94fb087..6506b21 100644 --- a/.github/workflows/pr_context_commenter.yaml +++ b/.github/workflows/pr_context_commenter.yaml @@ -19,10 +19,10 @@ jobs: // Create detailed comment with PR information from payload const comment = ` - - see the preview of the website at: https://enryh.github.io/notes_template/pr-${payload.number}/ + - see the preview of the website at: https://${context.repo.owner}.github.io/${context.repo.repo}/pr-${payload.number}/ - Repository: ${context.repo.repo} - - {context.repo.repo} + - ${context.repo.repo} ### Basic Information - PR Number: #${payload.number} From 53ec7ce3c95acc02a33c70b12e29fde271b3c445 Mon Sep 17 00:00:00 2001 From: Henry Webel Date: Tue, 23 Sep 2025 15:29:35 +0200 Subject: [PATCH 4/5] :art: clean-up message --- .github/workflows/pr_context_commenter.yaml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pr_context_commenter.yaml b/.github/workflows/pr_context_commenter.yaml index 6506b21..586e610 100644 --- a/.github/workflows/pr_context_commenter.yaml +++ b/.github/workflows/pr_context_commenter.yaml @@ -19,16 +19,8 @@ jobs: // 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}/ - - - Repository: ${context.repo.repo} - - ${context.repo.repo} - - ### Basic Information - - PR Number: #${payload.number} - - ### Author Information - - Author: @${payload.pull_request.user.login} + See the preview of the website at: + - https://${context.repo.owner}.github.io/${context.repo.repo}/pr-${payload.number}/ `; github.rest.issues.createComment({ From b9710363f4e412f74746a96876023a15d6b130a2 Mon Sep 17 00:00:00 2001 From: Henry Webel Date: Tue, 23 Sep 2025 15:36:59 +0200 Subject: [PATCH 5/5] :art: display name --- .github/workflows/pr_context_commenter.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr_context_commenter.yaml b/.github/workflows/pr_context_commenter.yaml index 586e610..7b62375 100644 --- a/.github/workflows/pr_context_commenter.yaml +++ b/.github/workflows/pr_context_commenter.yaml @@ -1,4 +1,4 @@ -name: PR Context Commenter +name: Publish Link of website for a Pull Request on: pull_request: @@ -21,6 +21,7 @@ jobs: 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({