Skip to content

Commit

Permalink
Create issue-auto-commenter.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
abhisek247767 authored Oct 19, 2024
1 parent 8c83f62 commit 9a56e1f
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/issue-auto-commenter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Issue Auto Commenter
on:
issues:
types: [opened]

env:
OWNER: 'abhisek247767'
REPO: 'Hello-World'

jobs:
comment:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Debug info
run: |
echo "Repository: ${{ github.repository }}"
echo "Issue number: ${{ github.event.issue.number }}"
echo "Owner: ${{ env.OWNER }}"
echo "Repo: ${{ env.REPO }}"
- name: Add comment to new issue
uses: actions/github-script@v7
env:
ISSUE_NUMBER: ${{ github.event.issue.number }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const owner = process.env.OWNER;
const repo = process.env.REPO;
const issue_number = process.env.ISSUE_NUMBER;
try {
console.log(`Attempting to comment on issue ${issue_number} in ${owner}/${repo}`);
const result = await github.rest.issues.createComment({
owner: owner,
repo: repo,
issue_number: parseInt(issue_number),
body: '👋 Thanks for opening this issue! First please star the repository and follow me in github. We appreciate your feedback and will look into it as soon as possible.'
});
console.log('API call details:', JSON.stringify({
method: 'POST',
url: `https://api.github.com/repos/${owner}/${repo}/issues/${issue_number}/comments`,
status: result.status,
data: result.data
}, null, 2));
console.log('Comment added successfully.');
} catch (error) {
core.setFailed(`Action failed with error: ${error.message}`);
}

0 comments on commit 9a56e1f

Please sign in to comment.