Repository: pulumi/actions (ts)

Issue:
Allow usage of local pulumi policy pack
We are trying to move from running plain pulumi cli in github actions to the actual `pulumi/action` since that would support editing/replacing the same PR comment instead of flooding the PR comments by the pulumi github app.

But the one feature I seem to be missing is the equivalent of the `--policy-pack ../pulumi-policy` CLI argument. We run a (large) monorepo and have the policy files in the same repo and refer to the locally when doing a pulumi up or preview.


Pull request description:
feat: add support for local policy packs
This adds support for specifying local policy packs and policy pack configs.

It needs to ship _after_ https://github.com/pulumi/pulumi/pull/9872 ships into a new version with the automation API deps bumped

Fixes #212

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aff230a..e000567 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
 
 ## HEAD (Unreleased)
 
+- feat: add support for local policy packs
+  [#658](https://github.com/pulumi/actions/pull/658)
+
 - fix: update PR comments correctly when `edit-pr-comment` is true (fixes
   [#633](https://github.com/pulumi/actions/issues/633))
 - bump to runtime to node 16
diff --git a/action.yml b/action.yml
index afbab11..b76e94f 100644
--- a/action.yml
+++ b/action.yml
@@ -55,6 +55,12 @@ inputs:
     description: 'Allows updating of dependent targets discovered but not specified in target.'
     required: false
     default: 'false'
+  policyPacks:
+    description: 'Run one or more policy packs as part of this update.'
+    required: false
+  policyPackConfigs:
+    description: 'Path to JSON file containing the config for the policy pack of the corresponding "--policy-pack" flag.'
+    required: false
   refresh:
     description: 'Perform a stack refresh as part of the operation'
     required: false
diff --git a/src/config.ts b/src/config.ts
index c014592..5f5a74f 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -19,6 +19,8 @@ export const options = rt.Partial({
   diff: rt.Boolean,
   replace: rt.Array(rt.String),
   target: rt.Array(rt.String),
+  policyPacks: rt.Array(rt.String),
+  policyPackConfigs: rt.Array(rt.String),
   targetDependents: rt.Boolean,
   editCommentOnPr: rt.Boolean,
   userAgent: rt.Literal('pulumi/actions@v3'),
@@ -65,6 +67,8 @@ export async function makeConfig(): Promise<Config> {
       replace: parseArray(getInput('replace')),
       target: parseArray(getInput('target')),
       targetDependents: parseBoolean(getInput('target-dependents')),
+      policyPacks: parseArray(getInput('policyPacks')),
+      policyPackConfigs: parseArray(getInput('policyPackConfigs')),
       editCommentOnPr: parseBoolean(getInput('edit-pr-comment')),
       userAgent: 'pulumi/actions@v3',
     },


Test patch:
diff --git a/src/__tests__/config.test.ts b/src/__tests__/config.test.ts
index a5e5060..abc9e6a 100644
--- a/src/__tests__/config.test.ts
+++ b/src/__tests__/config.test.ts
@@ -38,6 +38,8 @@ describe('config.ts', () => {
           "expectNoChanges": undefined,
           "message": undefined,
           "parallel": undefined,
+          "policyPackConfigs": undefined,
+          "policyPacks": undefined,
           "replace": undefined,
           "target": undefined,
           "targetDependents": undefined,
@@ -92,6 +94,8 @@ describe('config.ts', () => {
           "expectNoChanges": undefined,
           "message": undefined,
           "parallel": undefined,
+          "policyPackConfigs": undefined,
+          "policyPacks": undefined,
           "replace": undefined,
           "target": undefined,
           "targetDependents": undefined,