Skip to content

Commit

Permalink
use production_environments - a comma separated string
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Sep 15, 2023
1 parent a65073b commit b3290f0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions __tests__/functions/help.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const defaultInputs = {
stable_branch: 'main',
noop_trigger: '.noop',
lock_trigger: '.lock',
production_environment: 'production',
production_environments: 'production',
environment_targets: 'production,staging,development',
unlock_trigger: '.unlock',
help_trigger: '.help',
Expand Down Expand Up @@ -62,7 +62,7 @@ test('successfully calls help with non-defaults', async () => {
stable_branch: 'main',
noop_trigger: '.noop',
lock_trigger: '.lock',
production_environment: 'production',
production_environments: 'production',
environment_targets: 'production,staging,development',
unlock_trigger: '.unlock',
help_trigger: '.help',
Expand Down Expand Up @@ -93,7 +93,7 @@ test('successfully calls help with non-defaults', async () => {
stable_branch: 'main',
noop_trigger: '.noop',
lock_trigger: '.lock',
production_environment: 'production',
production_environments: 'production,production-eu,production-ap',
environment_targets: 'production,staging,development',
unlock_trigger: '.unlock',
help_trigger: '.help',
Expand Down
2 changes: 1 addition & 1 deletion __tests__/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ beforeEach(() => {
process.env.INPUT_ENVIRONMENT_TARGETS = 'production,development,staging'
process.env.INPUT_ENVIRONMENT_URLS = ''
process.env.INPUT_PARAM_SEPARATOR = '|'
process.env.INPUT_PRODUCTION_ENVIRONMENT = 'production'
process.env.INPUT_PRODUCTION_ENVIRONMENTS = 'production'
process.env.INPUT_STABLE_BRANCH = 'main'
process.env.INPUT_NOOP_TRIGGER = '.noop'
process.env.INPUT_LOCK_TRIGGER = '.lock'
Expand Down
22 changes: 11 additions & 11 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/functions/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ export async function help(octokit, context, reactionId, inputs) {
- \`${inputs.environment}\` - The default environment for this Action
- \`${
inputs.production_environment
}\` - The environment that is considered "production"
inputs.production_environments
}\` - The environments that are considered "production"
- \`${
inputs.environment_targets
}\` - The list of environments that can be targeted for deployment
Expand Down
18 changes: 9 additions & 9 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export async function run() {
const stable_branch = core.getInput('stable_branch')
const noop_trigger = core.getInput('noop_trigger')
const lock_trigger = core.getInput('lock_trigger')
const production_environment = core.getInput('production_environment')
const production_environments = await stringToArray(
core.getInput('production_environments')
)
const environment_targets = core.getInput('environment_targets')
const draft_permitted_targets = core.getInput('draft_permitted_targets')
const unlock_trigger = core.getInput('unlock_trigger')
Expand Down Expand Up @@ -169,7 +171,7 @@ export async function run() {
stable_branch: stable_branch,
noop_trigger: noop_trigger,
lock_trigger: lock_trigger,
production_environment: production_environment,
production_environments: production_environments,
environment_targets: environment_targets,
unlock_trigger: unlock_trigger,
global_lock_flag: global_lock_flag,
Expand Down Expand Up @@ -553,12 +555,10 @@ export async function run() {
})
}

// Check if the environment is a production_environment
var productionEnvironment = false
if (environment === production_environment.trim()) {
productionEnvironment = true
}
core.debug(`production_environment: ${productionEnvironment}`)
// Check if the environment is a production environment
const isProductionEnvironment =
production_environments.includes(environment)
core.debug(`production_environment: ${isProductionEnvironment}`)

// if update_branch is set to 'disabled', then set auto_merge to false, otherwise set it to true
const auto_merge = update_branch === 'disabled' ? false : true
Expand All @@ -573,7 +573,7 @@ export async function run() {
environment: environment,
// description: "",
// :description note: Short description of the deployment.
production_environment: productionEnvironment,
production_environment: isProductionEnvironment,
// :production_environment note: specifies if the given environment is one that end-users directly interact with. Default: true when environment is production and false otherwise.
payload: {
type: 'branch-deploy'
Expand Down

0 comments on commit b3290f0

Please sign in to comment.