Skip to content

Update auto-mergev2.yml #2348

Update auto-mergev2.yml

Update auto-mergev2.yml #2348

Workflow file for this run

name: Auto Comment
on:
issues:
types:
- opened
pull_request:
types:
- opened
jobs:
run:
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
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
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 $GH_COMMAND #$ITEM_NUMBER..."
echo -e "$COMMENT_BODY" | gh $GH_COMMAND comment $ITEM_NUMBER --body -
env:
COMMENT_BODY: ${{ env.COMMENT_BODY }}
ITEM_NUMBER: ${{ env.ITEM_NUMBER }}
GH_COMMAND: ${{ env.GH_COMMAND }}
shell: bash
if: env.GH_COMMAND != ''