Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 3

How to use the github-actions bot

Solved! Go to Solution.

I've created a couple of GitHub actions that add labels to an issue and assign it to a user. But, after the action executes the issue reflects that `user-a` has added labels `a` and `b`. This is probably because I'm using `user-a`s API token to authorise the adding of theses labels.

I'm looking for a way to authorise the `github-actions[bot]` to perform these operations so that users would know that they were triggered by automation.

Any help / links are appreciated. Thanks!

2 Replies
Solution
Copilot Lvl 3
Message 2 of 3

Re: How to use the github-actions bot

The GitHub Actions bot already has the permissions you want by default. Simply call the GitHub API using the token that is generated by GitHub Actions in the `GITHUB_TOKEN` secret. For example:

 

jobs:
  assign:
    runs-on: ubuntu-latest

steps: - name: Assign user env: PR_NUMBER: ${{ github.event.pull_request.number }} run: | curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -X POST -d '{"assignees": ["oldskool"]}' \ https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/assignees

 

Will result in the github-actions bot assigning me to the PR that triggered this workflow:

 

Screenshot 2019-10-10 at 16.05.46.png

Copilot Lvl 2
Message 3 of 3

Re: How to use the github-actions bot

Thanks so much @oldskool 

I had generated an API token and was using that to authenticate the Github API.
I was not aware of the default API token available already!