How can i specify my Personal Access Token in a github action when using Nektos/act to develop action steps locally?

Viewed 1683

I am trying to create my first github actions and run them locally, initially.

Whenever I try to run an action that involves interacting with the repo, eg checkout or try to create a branch, I get errors saying that there is no token set.

I am using nektos/act to run and debug my actions locally on a MacBook Pro. I have generated a Personal Access Token in github, and I have set env: GITHUB_TOKEN to the token in my yml code.

I understand that I can specify the token like this, when i am running the action within github itself:

- name: SomeStep
  id: some-step
  uses: peterjgrainger/action-create-branch@v1.0.0
  env:
     GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  with:
     branch: 'new-branch-name'

The above also does not seem to work currently, but I suspect that I have an issue elsewhere in my action.

To get to the bottom of that, I want to work on it locally - where the above secrets.GITHUB_TOKEN does not work. Neither does setting the token to the one I generated.

eg:

- name: SomeStep
      id: some-step
      uses: peterjgrainger/action-create-branch@v1.0.0
      env:
         GITHUB_TOKEN: abcde12345abc12345mypersonalaccesstokenhere
      with:
         branch: 'new-branch-name'

What might I be doing wrong?

1 Answers

Fir testing, check the issue 233

found that if one goes to Settings and Personal Access Tokens, and generate a new token: Make sure to remove all access except user and use this key in place of ${ secrets.GITHUB_TOKEN ) it solved my issue with this exact error.

Felt negligent not to mention that you should not commit this to your repository

(Note: using env or set-env is no longer supported, as stated in issue 384)

Related