action-create-branch icon indicating copy to clipboard operation
action-create-branch copied to clipboard

Token is never available - ❗ ::error::No token defined in the environment variables

Open devtrop-chrisjolley opened this issue 4 years ago • 2 comments

Having tried this a number of ways, including what is written in the readme example, I always get the below error.

❗ ::error::No token defined in the environment variables

 - name: Create a new branch
        uses: peterjgrainger/[email protected]
        env:
          GITHUB_TOKEN: abcde1234abcde1234etcetctec
        with:
          branch: 'release-notes'

Note the above is running locally, using "nektos/act". I have also tried running this in github itself using the below (which also fails)

- name: Create a new branch
        uses: peterjgrainger/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          branch: 'release-notes'

Can you advise?

devtrop-chrisjolley avatar Oct 15 '20 08:10 devtrop-chrisjolley

@devtrop-chrisjolley could be do do with indentation if you are using the yaml exactly as you've written above as yaml is sensitive to indentation. nektos act seems to be about 99% accurate when I've used it :)

I've created a repo showing both v2.0.0 and v2.0.1 working, maybe you can copy from there?

https://github.com/peterjgrainger/test-actions/blob/main/.github/workflows/create-branch.yml https://github.com/peterjgrainger/test-actions/runs/1268416600?check_suite_focus=true

- uses: peterjgrainger/[email protected]
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  with:
    branch: 'release-notes'

peterjgrainger avatar Oct 17 '20 12:10 peterjgrainger

Thanks Peter - I will check my indentation, but I have had this working fine with:

env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Its when i pass in a PAT directly:

env: GITHUB_TOKEN: somestringforatoken123...

it does not work for me, when trying to run the action locally using act

devtrop-chrisjolley avatar Oct 19 '20 09:10 devtrop-chrisjolley