Skip to content

Commit 203d3df

Browse files
committed
Fix auto-comment workflow - use proper JavaScript syntax
Issue: Workflow was using GitHub Actions template syntax inside JavaScript code Fix: Use JavaScript variables and template literals to access context data - Use context.payload.issue.user.login for issues - Use context.payload.pull_request.user.login for PRs - Use template literals (`${}`) instead of GitHub Actions ${{}} - Add await keyword for async operations - Add semicolons for proper JavaScript syntax The workflow will now properly comment on issues and PRs.
1 parent d2fced2 commit 203d3df

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

.github/workflows/auto-comment.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,24 @@ jobs:
2323
with:
2424
github-token: ${{ secrets.GITHUB_TOKEN }}
2525
script: |
26-
github.rest.issues.createComment({
26+
const username = context.payload.issue.user.login;
27+
await github.rest.issues.createComment({
2728
issue_number: context.issue.number,
2829
owner: context.repo.owner,
2930
repo: context.repo.repo,
30-
body: '@${{ github.event.issue.user.login }} Please Star ⭐️ the repo to earn \'**_hacktober-accepted_**\' label for the event.\nMeanwhile, if you want to work on this issue, please raise a PR, and we will review and merge it.'
31-
})
31+
body: `@${username} Please Star ⭐️ the repo to earn '**_hacktober-accepted_**' label for the event.\n\nMeanwhile, if you want to work on this issue, please raise a PR, and we will review and merge it.`
32+
});
3233
3334
- name: Comment on PR
3435
if: github.event_name == 'pull_request'
3536
uses: actions/github-script@v7
3637
with:
3738
github-token: ${{ secrets.GITHUB_TOKEN }}
3839
script: |
39-
github.rest.issues.createComment({
40+
const username = context.payload.pull_request.user.login;
41+
await github.rest.issues.createComment({
4042
issue_number: context.issue.number,
4143
owner: context.repo.owner,
4244
repo: context.repo.repo,
43-
body: '@${{ github.event.pull_request.user.login }} Please Star ⭐️ the repo to earn \'**_hacktober-accepted_**\' label for the event.'
44-
})
45+
body: `@${username} Please Star ⭐️ the repo to earn '**_hacktober-accepted_**' label for the event.`
46+
});

0 commit comments

Comments
 (0)