fix: only set environment_url when deployment succeeds#172
Open
AmSach wants to merge 27 commits into
Open
Conversation
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.
The API allows for updating the environment name when creating a status: https://docs.github.com/en/rest/deployments/statuses?apiVersion=2022-11-28#create-a-deployment-status
…bobheadxi#148) This reverts commit 9bf3b18.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixed issue #153 where deployments fail with 'invalid json response body' error when finishing deployments with non-success status.
The Problem
When calling
createDeploymentStatuswith an emptyenvironment_urlstring (i.e."") for failed/cancelled deployments, GitHub API returns an empty response causing JSON parse errors:The Fix
Only include the
environment_urlfield in the API request when:successenvURLvalue was actually providedThis 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 buildand verified the compiled output correctly uses conditional spread forenvironment_url.