-
Notifications
You must be signed in to change notification settings - Fork 456
TypeError: github.repos.createOrUpdateEnvironment is not a function - Octokit.js Support up-to-date? #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This issue is stale because it has been open for 60 days with no activity. Remove the "Stale" label or comment on the issue, or it will be closed in 7 days. |
Just ran into a similar issue: Several functions were added to Octokit here: octokit/octokit.js#2025 |
I got it to work with a modified version of this action (bumped deps): name: Secrets
on:
push:
branches:
- main
jobs:
set-secret:
name: Create or update environment secret
runs-on: ubuntu-latest
steps:
- name: Install tweetsodium
run: |
npm install tweetsodium
- uses: Simran-B/github-script@main # has updated dependencies (for testing only!)
id: update-secret
with:
github-token: ${{ secrets.PAT }} # Personal access token required
# (also for retrieving the env public key, despite what the documentation claims)
script: |
const sodium = require('tweetsodium')
const envName = "prod"
const secretName = "MY_SECRET"
const value = "New secret value"
const pkey = await github.rest.actions.getEnvironmentPublicKey({
repository_id: context.payload.repository.id,
environment_name: envName,
})
const messageBytes = Buffer.from(value)
const keyBytes = Buffer.from(pkey.data.key, "base64")
const encryptedBytes = sodium.seal(messageBytes, keyBytes)
const encrypted = Buffer.from(encryptedBytes).toString("base64")
const result = await github.rest.actions.createOrUpdateEnvironmentSecret({
repository_id: context.payload.repository.id,
environment_name: envName,
secret_name: secretName,
encrypted_value: encrypted,
key_id: pkey.data.key_id,
})
console.log(result.status) |
We're dealing with a similar issue, where we get a |
This issue is stale because it has been open for 60 days with no activity. Remove the "Stale" label or comment on the issue, or it will be closed in 7 days. |
Hello I'm also experiencing this issues with " |
I dug into it and saw that the oktokit versions in this action were very out of date, meaning they didn't expose many newer REST edpoints. I've bumped them up in #191 as far as they can go without breaking changes, and anyone can test it with action |
👋 This should now be fixed in v5 of this action - https://github.com/actions/github-script/releases/tag/v5.0.0 You'll need to use |
Is your feature request related to a problem? Please describe.
Trying to use github-script for environments but getting this error message:
TypeError: github.repos.createOrUpdateEnvironment is not a function
Describe the solution you'd like
Would you all be able to update the version of Octokit.js that supports Repo Environments
Describe alternatives you've considered
Using actions to post the HTTP response for environment creation
Additional context

Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: