Skip to content

fix: only set environment_url when deployment succeeds#172

Open
AmSach wants to merge 27 commits into
bobheadxi:masterfrom
AmSach:fix/empty-env-url-json-error
Open

fix: only set environment_url when deployment succeeds#172
AmSach wants to merge 27 commits into
bobheadxi:masterfrom
AmSach:fix/empty-env-url-json-error

Conversation

@AmSach
Copy link
Copy Markdown

@AmSach AmSach commented May 4, 2026

Summary

Fixed issue #153 where deployments fail with 'invalid json response body' error when finishing deployments with non-success status.

The Problem

When calling createDeploymentStatus with an empty environment_url string (i.e. "") for failed/cancelled deployments, GitHub API returns an empty response causing JSON parse errors:

The Fix

Only include the environment_url field in the API request when:

  1. The deployment status is success
  2. An envURL value was actually provided

This avoids sending empty strings to the GitHub API which causes it to return empty responses that can't be parsed as JSON.

Testing

Built with npm run build and verified the compiled output correctly uses conditional spread for environment_url.

bobheadxi and others added 27 commits February 21, 2022 10:53
Notable changes:

- CHANGED: no_override is now override, and the default behaviour is override: true in step: finish (step: start behaviour remains unchanged, but you can now set override: true on it now as well).
- CHANGED: log_args is now debug, but does the same thing as before.
- CHANGED: env is now always required. You can use env: ${{ steps.deployment.outputs.env }} to avoid repeating your env configuration.
- REMOVED: auto_inactive - use override instead.
- REMOVED: transient - all deployments created by this action are transient by default, with removals handled by override or step: deactivate.
- ADDED: step: delete-env deletes an environment entirely.
I realized after looking at the code that delete-env was deleting an environment, which isn't really related to deployments like the rest of this action (at least not in a way that mirrors deactivate-env like the README says).

I've added code here to do the delete in the way I expected it to work--deactivate all deployments for the given environment, then delete them.
bobheadxi#92 Mentions errors regarding deployments having the max number of statuses already set.

This PR avoids this from happening, by only setting the status if the status isn't already "inactive".

Co-authored-by: Robert Lin <robert@bobheadxi.dev>
fix bobheadxi#118

Co-authored-by: Robert Lin <robertlin1@gmail.com>
In 1.2.0 the token variable got a sensible default value so it doesn't need to be specified for the action to work.
Document that `token` now has a default.
Hi 👋🏻 
This PR adds a `task` input, that lets you change the task assigned to the deployment.

Other housekeeping changes:
- `test` script added to `package.json`
- `getOptionalInput` now can actually return `undefined` (empty strings can cause API errors)
- the CI workflow can now be used on other repos

Closes bobheadxi#140
When we get a 404 deleting an environment there should be a better
warning than "unexpected error encountered: HttpError: Not Found"
Document in the readme that the user for the PAT must have admin on the
repo, not just write or manage.

Co-authored-by: Robert Lin <robert@bobheadxi.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.