Skip to content

Commit

Permalink
Update auto-comment.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
fineanmol authored Sep 15, 2024
1 parent 00b3e9c commit 09f4f62
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions .github/workflows/auto-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,27 @@ jobs:
run:
runs-on: ubuntu-latest
steps:
- name: Check if it's an issue or pull request
- name: Set up variables
id: setup
run: |
if [[ ${{ github.event_name }} == 'issues' ]]; then
if [[ "${{ github.event_name }}" == 'issues' ]]; then
echo "COMMENT_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." >> $GITHUB_ENV
else
echo "ITEM_NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV
echo "GH_COMMAND=issue" >> $GITHUB_ENV
elif [[ "${{ github.event_name }}" == 'pull_request' ]]; then
echo "COMMENT_BODY=@${{ github.event.pull_request.user.login }} Please Star ⭐️ the repo to earn '**_hacktober-accepted_**' label for the event." >> $GITHUB_ENV
echo "ITEM_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
echo "GH_COMMAND=pr" >> $GITHUB_ENV
else
echo "Unsupported event type: ${{ github.event_name }}"
exit 1
fi
shell: bash

- name: Comment on issue/PR
run: |
echo "Commenting on issue/PR..."
comment_body="${{ env.COMMENT_BODY }}"
echo "$comment_body" | gh issue comment ${{ github.event.issue.number }} --body -
echo "Commenting on $GH_COMMAND #$ITEM_NUMBER..."
echo -e "$COMMENT_BODY" | gh $GH_COMMAND comment $ITEM_NUMBER --body -
env:
GITHUB_TOKEN: ${{ secrets.AUTOMERGE_TOKEN }}
if: ${{ github.event_name == 'issues' || github.event_name == 'pull_request' }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: env.GH_COMMAND != ''

0 comments on commit 09f4f62

Please sign in to comment.