Skip to content

🐞 : test

🐞 : test #6

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}`);
}