Home > Software engineering >  How to accept an invitation automatically to a GitHub repository?
How to accept an invitation automatically to a GitHub repository?

Time:12-29

Monthly I receive several invitations to be a collaborator of several Github repositories, unfortunately sometimes I miss the 7 days time to accept the invitations and as a consequence the invitations expire, making it impossible for me to access the repositories

I have tried to automate the invitations through GitHubActions but there is no such option.

Please, does anyone know how I can automate the acceptance of the invitations, so they will not expire after 7 days, which is the maximum time that Github grants before the invitations expire?

CodePudding user response:

I have tried to automate the invitations through GitHubActions but there is no such option.

You can test out the GitHub Action kbrashears5/github-action-auto-accept-collabs which should auto accept all collaboration invites.

It does:

  • get all repository invites for [${USERNAME}]
    curl -X GET -H "Accept: application/vnd.github.v3 json" -u ${USERNAME}:${GITHUB_TOKEN} \
         --silent ${GITHUB_API_URL}/user/repository_invitations | \
    jq '.[].id'
    
  • Accept each invite:
    curl -d @- \
          -X PATCH \
          -H "Accept: application/vnd.github.v3 json" \
          -u ${USERNAME}:${GITHUB_TOKEN} \
          --silent \
          ${GITHUB_API_URL}/user/repository_invitations/${invite}
    
  • Related