Skip to content

📃: Dutch_National_Flag #14

📃: Dutch_National_Flag

📃: Dutch_National_Flag #14

name: Issue Auto Commenter
on:
issues:
types: [opened]
env:
OWNER: 'abhisek247767'
REPO: 'LeetCode2024-6Companies30Days'
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;
console.log(`Debug: owner=${owner}, repo=${repo}, issue_number=${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) {
console.error('Error adding comment:', error.message);
console.error('Error details:', JSON.stringify(error, null, 2));
console.error('Stack trace:', error.stack);
core.setFailed(`Action failed with error: ${error.message}`);
}