Closed icculus closed 1 year ago
I don't think there's a way to get a token. At least, it is not available in the environment.
Until a few hours ago, the available versions were hardcoded in the action.
There are some advantages to hard coding:
The only cost is a higher maintenance burden, but this can be mitigated by some scripting.
No, I mean, the ${{ github.token }}
magic I mentioned works and provides a valid token to use, the question is whether we can force this into the GH_TOKEN
environment variable before running the gh
command line tool, but only if GH_TOKEN isn't already set.
Or maybe just always force it by default and add a simple "don't force it, I already handled it" option instead.
(Or maybe just force it and see if anyone ever complains, which they likely won't.)
I think this can only be done by adding a github-token
input.
If, and only if, that input is set, we set the GITHUB_TOKEN
/GH_TOKEN
environment variable(s).
Then you need to do use with
instead of env
:
- name: Set up SDL
id: sdl
uses: libsdl-org/setup-sdl@main
with:
version: 2-latest
github-token: ${{ github.token }}
wdyt?
Ah, okay, I think that'll do.
add default: ${{ github.token }}
in your inputs
Below this line
https://github.com/libsdl-org/setup-sdl/blob/2e6317af5c813de8c917a2ec724e26e03ff4a4b2/action.yml#L34
It's how that action that does git clone works (checkout)
Yes, we can.
Looks like it is also used by actions/checkout
.
I didn't know this was possible.
It's used by actions/checkout
.
I'm also going to rename github-token
to token
.
Applied in https://github.com/libsdl-org/setup-sdl/commit/a27f100fe1f5fba7c1cc35e2801ddd50c146e172. Thanks @ericoporto !
I had to add this to my GitHub Actions workflow step for setup-sdl:
Otherwise the
gh
call will fail. Is there a way to have setup-sdl itself set this environment variable for itself, but only if the workflow didn't specify something more specific?