From a0a5df31d5ab8af110b2a657a7e0c90a9e93f721 Mon Sep 17 00:00:00 2001 From: Dmitry Tsoy Date: Wed, 2 Nov 2022 15:50:30 +0500 Subject: [PATCH] add pulumi cancel action --- .github/workflows/workflow.yml | 4 ++-- README.md | 2 +- src/config.ts | 1 + src/main.ts | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 108a8489..b22cb289 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -52,7 +52,7 @@ jobs: name: Dotnet ${{ matrix.command }} on ${{ matrix.os }} strategy: matrix: - command: [up, refresh, destroy, preview] + command: [up, refresh, destroy, preview, cancel] os: [ubuntu-latest, macos-latest, windows-latest] fail-fast: false steps: @@ -86,7 +86,7 @@ jobs: name: Golang ${{ matrix.command }} on ${{ matrix.os }} strategy: matrix: - command: [up, refresh, destroy, preview] + command: [up, refresh, destroy, preview, cancel] os: [ubuntu-latest, macos-latest, windows-latest] fail-fast: false steps: diff --git a/README.md b/README.md index a3f245a5..322fd1f5 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ This will check out the existing directory and run `pulumi preview`. The action can be configured with the following arguments: - `command` (required) - The command to run as part of the action. Accepted - values are `up` (update), `refresh`, `destroy` and `preview`. + values are `up` (update), `refresh`, `destroy` `preview` and `cancel`. - `stack-name` (required) - The name of the stack that Pulumi will be operating on diff --git a/src/config.ts b/src/config.ts index eb0dcb24..b47e12ae 100644 --- a/src/config.ts +++ b/src/config.ts @@ -9,6 +9,7 @@ export const command = rt.Union( rt.Literal('refresh'), rt.Literal('destroy'), rt.Literal('preview'), + rt.Literal('cancel'), ); export type Commands = rt.Static; diff --git a/src/main.ts b/src/main.ts index f1ec31d2..72901ddc 100644 --- a/src/main.ts +++ b/src/main.ts @@ -67,7 +67,8 @@ const main = async () => { stack.refresh({ onOutput, ...config.options }).then((r) => r.stdout), destroy: () => stack.destroy({ onOutput, ...config.options }).then((r) => r.stdout), - preview: async () => { + cancel: async () => { await stack.cancel(); return "" }, + preview: async () => { const { stdout, stderr } = await stack.preview(config.options); onOutput(stdout); onOutput(stderr);