You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeError: github.rest.actions.getEnvironmentVariable is not a function
at eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15099:16), <anonymous>:3:43)
at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15100:12)
at main (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15[19](https://github.com/g2crowd/actions_test/actions/runs/4372190858/jobs/7648818737#step:2:20)8:26)
at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:15175:1
at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:15230:3
at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15233:12)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:8[22](https://github.com/g2crowd/actions_test/actions/runs/4372190858/jobs/7648818737#step:2:23):12)
Error: Unhandled error: TypeError: github.rest.actions.getEnvironmentVariable is not a function
TypeError: github.rest.actions.listRepoVariables is not a function
at eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15099:16), <anonymous>:16:42)
at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15100:12)
Error: Unhandled error: TypeError: github.rest.actions.listRepoVariables is not a function
at main (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15198:26)
at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:15175:1
at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:15230:3
at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15233:12)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
Can't use createRepoVariable, updateRepoVariable. I'd assume they're all part of the newer octokit.
Reacted by Josh Theisen, Bo Lingen and David Losert
TypeError: github.rest.actions.createRepoVariable is not a function
at eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15143:16), <anonymous>:3:21)
Error: Unhandled error: TypeError: github.rest.actions.createRepoVariable is not a function
at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15144:12)
at main (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15236:26)
at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:15217:1
at /home/runner/work/_actions/actions/github-script/v6/dist/index.js:15268:3
at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/v6/dist/index.js:15271:12)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
Hey @joshmgross - following up here now that I have a better understanding of using the github-script action and how to use it.
Is there a good way to know which github.rest.actions.xxx methods are currently available in the latest github-script version since others require the update like you mentioned above?
Is there a good way to know which github.rest.actions.xxx methods are currently available in the latest github-script version since others require the update like you mentioned above?
@joshmgross, I'm hitting some permissions errors hitting that specific endpoint. Any idea what permissions my job/workflow token needs to be able to have the environments:read scope?
I even tried with permissions: write-all set, but that didn't work. I'm assuming I'm gonna have to use a PAT if I want to call this?
@joshmgross, is there any special token handling needed to use github.request endpoint with github-script action?
When I used github.rest.actions.addSelectedRepoToOrgVariable in the github-script action, it encountered this error as expected, Error: Unhandled error: TypeError: github.rest.actions.addSelectedRepoToOrgVariable is not a function.
However, I tried using the github.request suggestion (with a token with org variable read/write permission), it encountered this error, Error: Unhandled error: SyntaxError: Invalid or unexpected token.
To confirm the token isn't the actual issue, I tested successfully using similar token (with org secret read/write permission) with github.rest.actions.addSelectedRepoToOrgSecret endpoint without issue.
However, it encountered similar invalid token error when switched to using github.request('PUT /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}'.
Disregard my previous comment. The invalid token error isn't related to the authentication token. Maybe during the code snippet copy for github.request function, some formatting / encoding got in the way. Rewriting it from scratch works fine.
As a workaround, you can use the request function directly.
await github.request('GET /repositories/{repository_id}/environments/{environment_name}/variables/{name}', {
repository_id: 'REPOSITORY_ID',
environment_name: 'ENVIRONMENT_NAME',
name: 'NAME',
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
})
Our API documentation has examples you can use: https://github.com/proxy/docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-an-environment-variable Just make sure to replace octokit with github, since this action exposes an authenticated Octokit instance as that github variable.
In 2025 it looks like the default github runner token still does not allow read / write on an action variable. I have to use a PAT. I wonder if this could be fixed?
Activity
mknet3 commentedon Mar 10, 2023
I think it is because some endpoints are not available in the
@octokit/plugin-rest-endpoint-methodsversion used v6.3.0. It is added in v6.8.0.INRIX-Iurii-Okhmat commentedon Mar 17, 2023
Same issue (different function, though):
Can't use
createRepoVariable,updateRepoVariable. I'd assume they're all part of the newer octokit.alex529 commentedon Apr 26, 2023
i'm experience the same issue, workflow:
and getting the following error in the output:
joshft91 commentedon May 11, 2023
This is what I'm running into. Are there any plans to update this to take advantage of the new api methods?
joshmgross commentedon May 11, 2023
This requires updating the version of used
@octokit/plugin-rest-endpoint-methodsby@actions/github, which this action depends on.https://github.com/actions/toolkit/blob/457303960f03375db6f033e214b9f90d79c3fe5c/packages/github/package.json#LL44C6-L44C43
Once that's updated, we can update this action.
As a workaround, you can use the
requestfunction directly.Our API documentation has examples you can use: https://github.com/proxy/docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-an-environment-variable
Just make sure to replace
octokitwithgithub, since this action exposes an authenticated Octokit instance as thatgithubvariable.joshft91 commentedon May 18, 2023
Hey @joshmgross - following up here now that I have a better understanding of using the
github-scriptaction and how to use it.Is there a good way to know which
github.rest.actions.xxxmethods are currently available in the latestgithub-scriptversion since others require the update like you mentioned above?joshmgross commentedon May 19, 2023
Based on https://stackoverflow.com/questions/152483/is-there-a-way-to-print-all-methods-of-an-object, I printed out all of the available endpoints for
github.rest.actions:https://github.com/joshmgross/actions-testing/actions/runs/5025713514/jobs/9013042586
Currently available endpoints
subrasub commentedon May 30, 2023
@joshmgross just wondering if there's any timeline on when the version would be updated?
joshmgross commentedon Jun 1, 2023
No timeline, I'm not sure if anything is tracking the update required to
@actions/githubin https://github.com/actions/toolkit#345 (comment)
eabrouwer3 commentedon Jun 9, 2023
@joshmgross, I'm hitting some permissions errors hitting that specific endpoint. Any idea what permissions my job/workflow token needs to be able to have the
environments:readscope?I even tried with
permissions: write-allset, but that didn't work. I'm assuming I'm gonna have to use a PAT if I want to call this?joshmgross commentedon Jun 9, 2023
The
environmentspermission is not available on the Actions token, so you'll need to use a PAT or separate GitHub App token.https://github.com/proxy/docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
travisgan commentedon Oct 4, 2023
@joshmgross, is there any special token handling needed to use
github.requestendpoint withgithub-scriptaction?When I used
github.rest.actions.addSelectedRepoToOrgVariablein the github-script action, it encountered this error as expected, Error: Unhandled error: TypeError: github.rest.actions.addSelectedRepoToOrgVariable is not a function.However, I tried using the
github.requestsuggestion (with a token with org variable read/write permission), it encountered this error, Error: Unhandled error: SyntaxError: Invalid or unexpected token.To confirm the token isn't the actual issue, I tested successfully using similar token (with org secret read/write permission) with
github.rest.actions.addSelectedRepoToOrgSecretendpoint without issue.However, it encountered similar invalid token error when switched to using
github.request('PUT /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}'.travisgan commentedon Oct 5, 2023
Disregard my previous comment. The invalid token error isn't related to the authentication token. Maybe during the code snippet copy for github.request function, some formatting / encoding got in the way. Rewriting it from scratch works fine.
ale5000-git commentedon Jan 20, 2025
Any update after some years?
ale5000-git commentedon Jan 20, 2025
I have tried with "permissions: write-all" this:
but I get "Resource not accessible by integration".
Have I done something wrong?
mikegarfinkle commentedon Mar 13, 2025
In 2025 it looks like the default github runner token still does not allow read / write on an action variable. I have to use a PAT. I wonder if this could be fixed?