Using GITHUB_TOKEN as a default input value

07 Oct 2022 in TIL

If you need to authenticate against the GitHub API in your GitHub Action, you might prompt the user to provide their GITHUB_TOKEN secret through an input. This isn't necessarily needed thanks to the github.token context and default input values.

You can gain access to the GITHUB_TOKEN secret by default by configuring your action.yml file to access github.token:

name: Action Name
description: My awesome description goes here
using: node12
main: dist/index.js
description: The GitHub token to use when calling the API
default: ${{ github.token }}
required: false