Skip to content

Commit

Permalink
Merge pull request #122 from Asymtode712/CloseIssFeat
Browse files Browse the repository at this point in the history
added workflow as mentioned in issue #119
  • Loading branch information
subhadeeproy3902 authored May 23, 2024
2 parents ddc9ee3 + 8175cf9 commit 65850be
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/autocomment-iss-close.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Comment on Issue Close # Name of the GitHub Action workflow

on:
issues:
types: [closed] # Trigger the workflow when an issue is closed

jobs:
greet-on-close:
runs-on: ubuntu-latest # Use the latest Ubuntu runner for the job
permissions:
issues: write # Grant permission to write to issues

steps:
- 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 }} # Use the GitHub token stored in secrets for authentication
script: |
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!`; # Create a greeting message
// Use the GitHub API to create a comment on the closed issue
github.rest.issues.createComment({
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
});

0 comments on commit 65850be

Please sign in to comment.