Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Refresh #128

Merged
merged 8 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
cloud-url: file://~
stack-name: dev
work-dir: .github/test-stacks/golang
- run: echo "The random string is ${{ steps.pulumi.outputs.name }}"
- run: echo "The random string is `${{ steps.pulumi.outputs.name }}`"
35 changes: 34 additions & 1 deletion .github/workflows/workflow_options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
test-workflow:
runs-on: ${{ matrix.os }}
name: Testing Pulumi ${{ matrix.command }} on ${{ matrix.os }}
name: Testing arguments - ${{ matrix.command }} on ${{ matrix.os }}
strategy:
matrix:
command: [ up, refresh, destroy, preview ]
Expand Down Expand Up @@ -43,3 +43,36 @@ jobs:
message: this-is-just-a-test
expect-no-changes: false
diff: true
test-refresh-and-upsert:
runs-on: ${{ matrix.os }}
name: Testing refresh/upsert – ${{ matrix.command }} on ${{ matrix.os }}
strategy:
matrix:
command: [ up, refresh, destroy, preview ]
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Install pulumi
uses: pulumi/action-install-pulumi-cli@v1.0.1
- name: Create local stack
run: |
pulumi login --local
working-directory: .github/test-stacks/nodejs
env:
PULUMI_CONFIG_PASSPHRASE: not-a-secret
- run: npm install
working-directory: .github/test-stacks/nodejs
- uses: ./
env:
PULUMI_CONFIG_PASSPHRASE: not-a-secret
with:
command: ${{ matrix.command }}
cloud-url: file://~
stack-name: dev
work-dir: .github/test-stacks/nodejs
upsert: true
refresh: true
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## HEAD (Unreleased)

_(none)_
- Add ability to refresh a stack by passing `refresh: true`
[#128](https://github.com/pulumi/actions/pull/128)

---

Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The action can be configured with the following arguments:

- `command` (required) - The command to pass to the Pulumi CLI. Accepted values
are `up` (update), `refresh`, `destroy` and `preview`. This command is the
equivalent of running `pulumi <command>` if your terminal.
equivalent of running `pulumi <command>` if your terminal.

- `stack-name` (required) - The name of the stack that Pulumi will be operating
on
Expand All @@ -60,6 +60,9 @@ The action can be configured with the following arguments:
- `github-token` - (required if comment-on-pr) A GitHub token that has access
levels to allow the Action to comment on a PR.

- `refresh` - (optional) If `true`, stack is refreshed before running the
`command`.

### Extra options

- `parallel` - (optional) Allow P resource operations to run in parallel at once
Expand All @@ -81,6 +84,11 @@ The action can be configured with the following arguments:

- `target-dependents` - (optional) Allows updating of dependent targets
discovered but not specified in target.
- `upsert` - (optiona) Allows the creation of the specified stack if it
currently doesn't exist.
**PLEASE NOTE:** This will create a Pulumi.<stack-name>.yaml file that you
will need to add back to source control as part of the action if you wish to
perform any further tasks with that stack.

By default, this action will try to authenticate Pulumi with the
[Pulumi SaaS](https://app.pulumi.com/). If you have not specified a
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ inputs:
description: 'Allows updating of dependent targets discovered but not specified in target.'
required: false
default: 'false'
refresh:
description: 'Perform a stack refresh as part of the operation'
required: false
default: 'false'
upsert:
description: 'Create the stack if it currently does not exist'
required: false
default: 'false'
outputs:
output:
description: Output from running command
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const config = rt
cloudUrl: rt.String,
githubToken: rt.String,
upsert: rt.Boolean,
refresh: rt.Boolean,
}),
);

Expand All @@ -51,6 +52,7 @@ export async function makeConfig(): Promise<Config> {
githubToken: getInput('github-token'),
commentOnPr: parseBoolean(getInput('comment-on-pr')),
upsert: parseBoolean(getInput('upsert')),
refresh: parseBoolean(getInput('refresh')),
options: {
parallel: parseNumber(getInput('parallel')),
message: getInput('message'),
Expand Down
10 changes: 8 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,19 @@ const main = async () => {
? LocalWorkspace.createOrSelectStack(stackArgs)
: LocalWorkspace.selectStack(stackArgs));

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

const onOutput = (msg: string) => {
core.debug(msg);
core.info(msg);
};

if (config.refresh) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this - separating the refresh out of the log group :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thanks!

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

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

const actions: Record<Commands, () => Promise<string>> = {
up: () => stack.up({ onOutput, ...config.options }).then((r) => r.stdout),
update: () =>
Expand Down