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: specify separate targets for dev and production #572

Merged
Changes from 1 commit
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
Prev Previous commit
fix: refactor logic and improve documentation
groozin committed Feb 8, 2024
commit 2d42b52b74eab9764e2c876d33a42a9f303ffd6f
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -26,14 +26,14 @@ inputs:
required: false
default: false
target:
description: 'Auto-merge on major, minor, patch updates based on Semantic Versioning for both dev and production dependencies'
description: 'Auto-merge on updates based on Semantic Versioning'
required: false
default: 'any'
target-development:
description: 'Auto-merge on major, minor, patch updates based on Semantic Versioning when dependency is a dev dependency'
description: 'Auto-merge on updates based on Semantic Versioning for development dependencies'
required: false
target-production:
description: 'Auto-merge on major, minor, patch updates based on Semantic Versioning when dependency is a production dependency'
description: 'Auto-merge on updates based on Semantic Versioning for production dependencies'
required: false
pr-number:
description: 'A pull request number, only required if triggered from a workflow_dispatch event'
31 changes: 18 additions & 13 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -2870,6 +2870,7 @@ const {
MERGE_STATUS_KEY,
getInputs,
parseCommaOrSemicolonSeparatedValue,
getTarget,
} = __nccwpck_require__(483)
const { verifyCommits } = __nccwpck_require__(425)
const { dependabotAuthor } = __nccwpck_require__(663)
@@ -2901,19 +2902,6 @@ module.exports = async function run({
SKIP_VERIFICATION,
} = getInputs(inputs)

let target = TARGET
if (
dependabotMetadata.dependencyType === 'direct:development' &&
TARGET_DEV
) {
target = TARGET_DEV
} else if (
dependabotMetadata.dependencyType === 'direct:production' &&
TARGET_PROD
) {
target = TARGET_PROD
}

try {
toolkit.logActionRefWarning()

@@ -2958,6 +2946,11 @@ module.exports = async function run({
}
}

const target = getTarget(
{ TARGET, TARGET_DEV, TARGET_PROD },
dependabotMetadata,
)

if (
target !== updateTypes.any &&
updateTypesPriority.indexOf(updateType) < 0
@@ -3273,6 +3266,18 @@ exports.getInputs = inputs => {
}
}

exports.getTarget = (
{ TARGET, TARGET_DEV, TARGET_PROD },
{ dependencyType },
) => {
if (dependencyType === 'direct:development' && TARGET_DEV) {
return TARGET_DEV
} else if (dependencyType === 'direct:production' && TARGET_PROD) {
return TARGET_PROD
}
return TARGET
}

exports.MERGE_STATUS = {
approved: 'approved',
merged: 'merged',
19 changes: 6 additions & 13 deletions src/action.js
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ const {
MERGE_STATUS_KEY,
getInputs,
parseCommaOrSemicolonSeparatedValue,
getTarget,
} = require('./util')
const { verifyCommits } = require('./verifyCommitSignatures')
const { dependabotAuthor } = require('./getDependabotDetails')
@@ -42,19 +43,6 @@ module.exports = async function run({
SKIP_VERIFICATION,
} = getInputs(inputs)

let target = TARGET
if (
dependabotMetadata.dependencyType === 'direct:development' &&
TARGET_DEV
) {
target = TARGET_DEV
} else if (
dependabotMetadata.dependencyType === 'direct:production' &&
TARGET_PROD
) {
target = TARGET_PROD
}

try {
toolkit.logActionRefWarning()

@@ -99,6 +87,11 @@ module.exports = async function run({
}
}

const target = getTarget(
{ TARGET, TARGET_DEV, TARGET_PROD },
dependabotMetadata,
)

if (
target !== updateTypes.any &&
updateTypesPriority.indexOf(updateType) < 0
12 changes: 12 additions & 0 deletions src/util.js
Original file line number Diff line number Diff line change
@@ -56,6 +56,18 @@ exports.getInputs = inputs => {
}
}

exports.getTarget = (
{ TARGET, TARGET_DEV, TARGET_PROD },
{ dependencyType },
) => {
if (dependencyType === 'direct:development' && TARGET_DEV) {
return TARGET_DEV
} else if (dependencyType === 'direct:production' && TARGET_PROD) {
return TARGET_PROD
}
return TARGET
}

exports.MERGE_STATUS = {
approved: 'approved',
merged: 'merged',