From 6ae9484e5be140ccd145ffa886569992b8d7d395 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Thu, 10 Apr 2025 11:16:50 +0100 Subject: [PATCH] Update PR-Demo-Comment-with-react.yml (#3328) # Description of Changes Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing) for more details. --- .../workflows/PR-Demo-Comment-with-react.yml | 76 +++++++++++-------- 1 file changed, 45 insertions(+), 31 deletions(-) diff --git a/.github/workflows/PR-Demo-Comment-with-react.yml b/.github/workflows/PR-Demo-Comment-with-react.yml index 47efbf82c..4a0736f54 100644 --- a/.github/workflows/PR-Demo-Comment-with-react.yml +++ b/.github/workflows/PR-Demo-Comment-with-react.yml @@ -6,13 +6,12 @@ on: permissions: contents: read + issues: write # Required for adding reactions to comments + pull-requests: read # Required for reading PR information jobs: check-comment: runs-on: ubuntu-latest - permissions: - pull-requests: read - issues: read if: | github.event.issue.pull_request && ( @@ -75,24 +74,31 @@ jobs: core.setOutput('ref', pr.head.ref); - name: Add 'in_progress' reaction to comment + id: add-eyes-reaction uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 with: script: | - const { owner, repo } = context.repo; - const commentId = context.payload.comment.id; - - await github.rest.reactions.createForIssueComment({ - owner, - repo, - comment_id: commentId, - content: 'eyes' - }); + console.log(`Adding eyes reaction to comment ID: ${context.payload.comment.id}`); + try { + const { data: reaction } = await github.rest.reactions.createForIssueComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: context.payload.comment.id, + content: 'eyes' + }); + console.log(`Added reaction with ID: ${reaction.id}`); + return { success: true, id: reaction.id }; + } catch (error) { + console.error(`Failed to add reaction: ${error.message}`); + console.error(error); + return { success: false, error: error.message }; + } deploy-pr: needs: check-comment runs-on: ubuntu-latest permissions: - pull-requests: write + contents: read issues: write steps: @@ -201,30 +207,38 @@ jobs: uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 with: script: | - const { owner, repo } = context.repo; - const commentId = ${{ needs.check-comment.outputs.comment_id }}; - - await github.rest.reactions.createForIssueComment({ - owner, - repo, - comment_id: commentId, - content: 'rocket' - }); + console.log(`Adding rocket reaction to comment ID: ${{ needs.check-comment.outputs.comment_id }}`); + try { + const { data: reaction } = await github.rest.reactions.createForIssueComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: ${{ needs.check-comment.outputs.comment_id }}, + content: 'rocket' + }); + console.log(`Added rocket reaction with ID: ${reaction.id}`); + } catch (error) { + console.error(`Failed to add reaction: ${error.message}`); + console.error(error); + } - name: Add failure reaction to comment if: failure() uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 with: script: | - const { owner, repo } = context.repo; - const commentId = ${{ needs.check-comment.outputs.comment_id }}; - - await github.rest.reactions.createForIssueComment({ - owner, - repo, - comment_id: commentId, - content: '-1' - }); + console.log(`Adding -1 reaction to comment ID: ${{ needs.check-comment.outputs.comment_id }}`); + try { + const { data: reaction } = await github.rest.reactions.createForIssueComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: ${{ needs.check-comment.outputs.comment_id }}, + content: '-1' + }); + console.log(`Added -1 reaction with ID: ${reaction.id}`); + } catch (error) { + console.error(`Failed to add reaction: ${error.message}`); + console.error(error); + } - name: Post deployment URL to PR if: success()