From 7f97c013cb3b7d659e3641c266e678085c7f7872 Mon Sep 17 00:00:00 2001 From: Siddheya Kulkarni <115717746+Asymtode712@users.noreply.github.com> Date: Tue, 21 May 2024 17:17:01 +0530 Subject: [PATCH 1/2] created autocomment-iss-close.yml --- .github/workflows/autocomment-iss-close.yml | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/autocomment-iss-close.yml diff --git a/.github/workflows/autocomment-iss-close.yml b/.github/workflows/autocomment-iss-close.yml new file mode 100644 index 0000000..3acbe0a --- /dev/null +++ b/.github/workflows/autocomment-iss-close.yml @@ -0,0 +1,29 @@ +name: Comment on Issue Close + +on: + issues: + types: [closed] + +jobs: + greet-on-close: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Greet User + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const issue = context.payload.issue; + const issueCreator = issue.user.login; + const issueNumber = issue.number; + + const greetingMessage = `Hello @${issueCreator}! Your issue #${issueNumber} has been closed. Thank you for your contribution!`; + + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issueNumber, + body: greetingMessage + }); \ No newline at end of file From 8175cf96e23a084cdee260c6253da3f5d8c6bc35 Mon Sep 17 00:00:00 2001 From: Siddheya Kulkarni <115717746+Asymtode712@users.noreply.github.com> Date: Thu, 23 May 2024 02:47:55 +0530 Subject: [PATCH 2/2] Update autocomment-iss-close.yml --- .github/workflows/autocomment-iss-close.yml | 34 +++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/autocomment-iss-close.yml b/.github/workflows/autocomment-iss-close.yml index 3acbe0a..70f33d7 100644 --- a/.github/workflows/autocomment-iss-close.yml +++ b/.github/workflows/autocomment-iss-close.yml @@ -1,29 +1,31 @@ -name: Comment on Issue Close +name: Comment on Issue Close # Name of the GitHub Action workflow on: issues: - types: [closed] + types: [closed] # Trigger the workflow when an issue is closed jobs: greet-on-close: - runs-on: ubuntu-latest + runs-on: ubuntu-latest # Use the latest Ubuntu runner for the job permissions: - issues: write + issues: write # Grant permission to write to issues + steps: - - name: Greet User - uses: actions/github-script@v5 + - name: Greet User # Step to greet the user when the issue is closed + uses: actions/github-script@v5 # Use the GitHub script action to run a custom script with: - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} # Use the GitHub token stored in secrets for authentication script: | - const issue = context.payload.issue; - const issueCreator = issue.user.login; - const issueNumber = issue.number; + const issue = context.payload.issue; # Get the issue details from the context payload + const issueCreator = issue.user.login; # Get the username of the issue creator + const issueNumber = issue.number; # Get the issue number - const greetingMessage = `Hello @${issueCreator}! Your issue #${issueNumber} has been closed. Thank you for your contribution!`; + const greetingMessage = `Hello @${issueCreator}! Your issue #${issueNumber} has been closed. Thank you for your contribution!`; # Create a greeting message + // Use the GitHub API to create a comment on the closed issue github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issueNumber, - body: greetingMessage - }); \ No newline at end of file + owner: context.repo.owner, # Repository owner + repo: context.repo.repo, # Repository name + issue_number: issueNumber, # Issue number + body: greetingMessage # Comment body with the greeting message + });