Repository navigation
TypeError: github.repos.createOrUpdateEnvironment is not a function - Octokit.js Support up-to-date? #133
Description
Activity
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:
Error: Unhandled error: TypeError: github.actions.getEnvironmentPublicKey is not a functionSeveral functions were added to Octokit here: octokit/octokit.js#2025
I supposegithub-scriptneeds to bump its dependencies?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
TypeError: github.repos.deleteAnEnvironment is not a function(butgithub.repos.createDeploymentStatusin the immediately prior job step succeeds)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 "
github.repos.deleteAnEnvironmentis not a function", which is frustrating as we're trying to clean up environments we create per PR.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
ironsean/github-script@v-testfor now if they'd like.👋 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
github.rest.repos.createOrUpdateEnvironmentdue to breaking changes in Octokit, see https://github.com/actions/github-script#breaking-changes-in-v5Reacted by Kimmo Ahokas
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 functionDescribe 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.