Skip to content

Commit

Permalink
Change refresh behavior to use --refresh flag (#1118)
Browse files Browse the repository at this point in the history
* Add  config option

* update changelog

* Add new flag to action.yml

* Breaking change, refresh=true now uses --refresh

* Add v6 migration notes

* merge fix

* cleanup

* fixup tests

---------

Co-authored-by: Thomas Gummerer <[email protected]>
  • Loading branch information
fitz-vivodyne and tgummerer authored Sep 9, 2024
1 parent cd99a7f commit f1948a3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## HEAD (Unreleased)

- feat: (breaking change) Update the `refresh` option to runcommands with the
`--refresh` flag. ([#1118](https://github.com/pulumi/actions/pull/1118))

---

## 5.5.1 (2024-08-23)
Expand Down
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pulumi/actions@v5
- uses: pulumi/actions@v6
with:
command: preview
stack-name: org-name/stack-name
Expand Down Expand Up @@ -60,8 +60,8 @@ The action can be configured with the following arguments:
- `github-token` - (optional) A GitHub token that has access levels to allow the
Action to comment on a PR. Defaults to `${{ github.token }}`

- `refresh` - (optional) If `true`, stack is refreshed before running the
`command`.
- `refresh` - (optional) If `true`, `preview` and `up` commands are called with
the `--refresh` flag.

- `secrets-provider` - (optional) The type of the provider that should be used
to encrypt and decrypt secrets. Possible choices: `default`, `passphrase`,
Expand Down Expand Up @@ -165,7 +165,7 @@ If you want to only install the Pulumi CLI, omit the `command` field of the
action.

```yaml
- uses: pulumi/actions@v5
- uses: pulumi/actions@v6
```

This will install Pulumi and exit without performing any other operations.
Expand Down Expand Up @@ -199,7 +199,7 @@ We can see that `pet-name` is an output. To get the value of this output in the
action, we would use code similar to the following:

```yaml
- uses: pulumi/actions@v5
- uses: pulumi/actions@v6
id: pulumi
env:
PULUMI_CONFIG_PASSPHRASE: ${{ secrets.PULUMI_CONFIG_PASSPHRASE }}
Expand Down Expand Up @@ -248,6 +248,13 @@ Minor releases will be published around the beginning of the month. We may cut a
patch release instead, if the changes are small enough not to warrant a minor
release. We will also cut patch releases periodically as needed to address bugs.
## Migrating from v5
v6 of the Pulumi Action updates the behavior of the `refresh` option.
Previously, if `refresh` was true, the action would run `pulumi refresh` before
the desired command. In v6, the `pulumi up` and `pulumi preview` commands will
be run with the `--refresh` flag if `refresh` is true.
## Migrating from v4
v5 of the Pulumi Action updates the NodeJS runtime from Node 16 to Node 20.
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ inputs:
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'
description: 'Execute the operation with the `--refresh` option'
required: false
default: 'false'
upsert:
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('config.ts', () => {
"plan": "",
"policyPackConfigs": Array [],
"policyPacks": Array [],
"refresh": false,
"replace": Array [],
"suppressOutputs": false,
"suppressProgress": false,
Expand All @@ -67,7 +68,6 @@ describe('config.ts', () => {
"userAgent": "pulumi/actions@v5",
},
"pulumiVersion": "^3",
"refresh": false,
"remove": false,
"secretsProvider": "",
"stackName": "dev",
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export function makeConfig() {
commentOnSummary: getBooleanInput('comment-on-summary'),
upsert: getBooleanInput('upsert'),
remove: getBooleanInput('remove'),
refresh: getBooleanInput('refresh'),
// TODO: Add parser back once pulumi/pulumi#12641 is fixed.
// @see https://github.com/pulumi/actions/pull/913
// @see https://github.com/pulumi/actions/pull/912
Expand All @@ -99,6 +98,7 @@ export function makeConfig() {
message: getInput('message'),
expectNoChanges: getBooleanInput('expect-no-changes'),
diff: getBooleanInput('diff'),
refresh: getBooleanInput('refresh'),
replace: parseSemicolorToArray(getMultilineInput('replace')),
target: parseSemicolorToArray(getMultilineInput('target')),
targetDependents: getBooleanInput('target-dependents'),
Expand Down
5 changes: 0 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ const runAction = async (config: Config): Promise<void> => {
await stack.setAllConfig(config.configMap);
}

if (config.refresh) {
core.startGroup(`Refresh stack on ${config.stackName}`);
await stack.refresh({ onOutput });
core.endGroup();
}

core.startGroup(`pulumi ${config.command} on ${config.stackName}`);

Expand Down

0 comments on commit f1948a3

Please sign in to comment.