Skip to content

Commit

Permalink
safe workflow inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
cnuss committed Mar 29, 2024
1 parent 0088117 commit 0680a5d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class Action {
state.action = 'destroy';
} else if (
GITHUB_EVENT_NAME === 'workflow_dispatch' &&
boolean(context.payload.inputs.destroy) === true
boolean(this.workflowInputs.destroy) === true
) {
notice(`Workflow dispatch triggered with destruction enabled. Destroying ${this.stage}...`);
state.action = 'destroy';
Expand Down Expand Up @@ -345,7 +345,11 @@ export class Action {
return GITHUB_REF.endsWith('/merge');
}

get branchName(): string {
get workflowInputs(): { [key: string]: string } {
return context.payload.inputs || {};
}

get deploymentRef(): string {
if (!GITHUB_REF) {
throw new Error('Unable to determine branch from GITHUB_REF');
}
Expand Down Expand Up @@ -375,7 +379,7 @@ export class Action {

try {
const response = await octokit.rest.repos.createDeployment({
ref: this.branchName,
ref: this.deploymentRef,
required_contexts: [],
environment: this.stage,
transient_environment: this.isPr,
Expand Down

0 comments on commit 0680a5d

Please sign in to comment.