-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c83f62
commit 9a56e1f
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`); | ||
} |