How to trigger event on first successful merge by authors using github action?

I want to append the name of every user on their first successful PR merge. My current understanding is -

name: Add to Contributors
on:
  push:
    branches:
    - master

jobs:
  comment:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/first-interaction@v1
      with:
        repo-token: ${{ secrets.GITHUB_TOKEN }}
        pr-message: 'Adding this new user to Contributors...'

Here I want to take output in some variable like isFirst and username and then create a pull request if isFirst is true;
How should I proceed? is there any alternative way?

@theSwapnilSaste Thanks for your feedback.
Through the action code, we find that this variable( firstContribution) is checked in the main.js line55. Based on your needs, you could try to append username when you add message. Such as:

jobs:
  comment:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/first-interaction@v1
        with:
          repo-token: ${{ secrets.TEST_TOKEN }}
          pr-message: 'Adding this ${{ github.event.pull_request.user.login }} to Contributors...'
          issue-message: 'Adding this ${{ github.event.issue.user.login }} to Contributors...'

The result:

1 Like

@niconbw Can you tell how to add this username to README.md at the end in append mode ? I am new with actions.

Hi @theSwapnilSaste
Please try to use git command to update README.md. Such as:

name: Add to Contributors
on:
  pull_request:
    branches:
    - master

jobs:
  comment:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
   
    - name: Modify README.md
      run: |
        echo '<br> Adding this ${{ github.event.pull_request.user.login }} to Contributors' >> README.md
        
    - name: Commit files
      run: |
          git config --local user.email "test@github.com"
          git config --local user.name "GitHub Action test"
          git add ./README.md
          git commit -m "Add Contributors"
    - name: Push changes # push the README.md to your repo
      uses: ad-m/github-push-action@master
      with:
        branch: master #ignore if your branch is master
        github_token: ${{ secrets.GITHUB_TOKEN }}
        force: true

Hi @theSwapnilSaste
Did the git command meet your needs? Feel free to contact me if there is any questions related to this ticket.