Skip to content

Commit

Permalink
start: add 'payload' parameter (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobheadxi authored Feb 28, 2022
1 parent 86fa294 commit b0db961
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ In addition to the [core configuration](#configuration), the following [`inputs`
| --------------- | ------- | --------------------------------------------------------------------------------------------------- |
| `deployment_id` | | Use an existing deployment instead of creating a new one (e.g. `${{ github.event.deployment.id }}`) |
| `override` | `false` | whether to mark existing deployments of this environment as inactive |
| `payload` | | JSON-formatted dictionary with extra information about the deployment |

The following [`outputs`](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#steps-context) are available:

Expand Down Expand Up @@ -161,13 +162,13 @@ This is best used after `step: start` and should follow whatever deployment task

In addition to the [core configuration](#configuration), the following [`inputs`](https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idstepswith) are available:

| Variable | Default | Purpose |
| --------------- | ------- | --------------------------------------------------------------------------------- |
| `status` | | provide the current deployment job status `${{ job.status }}` |
| `deployment_id` | | identifier for deployment to update (see outputs of [`step: start`](#step-start)) |
| `env_url` | | URL to view deployed environment |
| `override` | `true` | whether to manually mark existing deployments of this environment as inactive |
| `auto_inactive` | `true` | whether to let GitHub handle marking existing deployments of this environment as inactive ([if and only if a new deployment succeeds](https://docs.github.com/en/rest/reference/deployments#inactive-deployments)). |
| Variable | Default | Purpose |
| --------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `status` | | provide the current deployment job status `${{ job.status }}` |
| `deployment_id` | | identifier for deployment to update (see outputs of [`step: start`](#step-start)) |
| `env_url` | | URL to view deployed environment |
| `override` | `true` | whether to manually mark existing deployments of this environment as inactive |
| `auto_inactive` | `true` | whether to let GitHub handle marking existing deployments of this environment as inactive ([if and only if a new deployment succeeds](https://docs.github.com/en/rest/reference/deployments#inactive-deployments)). |

<details>
<summary>Simple Example</summary>
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ inputs:
required: false
description: Whether to mark existing deployments as inactive if a deployment succeeds (for `finish` only)
default: 'false'
payload:
required: false
description: JSON-formatted dictionary with extra information about the deployment (for `start` only)
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/steps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ export async function run(
switch (step) {
case Step.Start:
{
const rawPayload = getOptionalInput("payload");
let payload: { [key: string]: any } | undefined = undefined;
if (rawPayload) {
payload = JSON.parse(rawPayload);
}
const stepArgs: StartArgs = {
deploymentID: getOptionalInput("deployment_id"),
override: getBooleanInput("override", false), // default to false on start
payload,
};
log.debug(`'${step}' arguments`, {
stepArgs,
Expand Down
2 changes: 2 additions & 0 deletions src/steps/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import deactivateEnvironment from "../lib/deactivate";
export type StartArgs = {
deploymentID?: string;
override: boolean;
payload?: { [key: string]: any };
};

async function createStart(
Expand Down Expand Up @@ -37,6 +38,7 @@ async function createStart(
description: description,
auto_merge: false,
transient_environment: true,
payload: stepArgs.payload,
});
if (deployment.status == 201) {
deploymentID = deployment.data.id;
Expand Down

0 comments on commit b0db961

Please sign in to comment.