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 d80e764 commit ad587ad
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions .github/workflows/auto-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,34 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check if it's an issue or pull request
id: determine_event
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: Authenticate GitHub CLI
run: echo "${{ secrets.AUTOMERGE_TOKEN }}" | gh auth login --with-token
env:
GITHUB_TOKEN: ${{ secrets.AUTOMERGE_TOKEN }}

- 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' }}
COMMENT_BODY: ${{ env.COMMENT_BODY }}
ITEM_NUMBER: ${{ env.ITEM_NUMBER }}
GH_COMMAND: ${{ env.GH_COMMAND }}
shell: bash
if: env.GH_COMMAND != ''

0 comments on commit ad587ad

Please sign in to comment.