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

DevOps extension task new updater commands and options #1216

Merged
merged 15 commits into from
Jul 18, 2024
11 changes: 11 additions & 0 deletions extension/task/IDependabotConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,19 @@ export interface IDependabotUpdate {
packageEcosystem: string;
/**
* Location of package manifests.
* https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#directory
* */
directory: string;
/**
* Locations of package manifests.
* https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#directories
* */
directories?: string[];
/**
* Dependency group rules
* https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#groups
* */
groups?: string;
/**
* Customize which updates are allowed.
*/
Expand Down
58 changes: 56 additions & 2 deletions extension/task/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ async function run() {
dockerRunner.arg(["--rm"]); // remove after execution
dockerRunner.arg(["-i"]); // attach pseudo tty

// Set the job id, if one is provided
if (variables.jobId) {
dockerRunner.arg(["-e", `DEPENDABOT_JOB_ID=${variables.jobId}`]);
}

// Set the github token, if one is provided
if (variables.githubAccessToken) {
dockerRunner.arg(["-e", `GITHUB_ACCESS_TOKEN=${variables.githubAccessToken}`]);
Expand All @@ -58,10 +63,13 @@ async function run() {
dockerRunner.arg(["-e", `DEPENDABOT_PACKAGE_MANAGER=${update.packageEcosystem}`]);
dockerRunner.arg(["-e", `DEPENDABOT_OPEN_PULL_REQUESTS_LIMIT=${update.openPullRequestsLimit}`]); // always has a value

// Set the directory
// Set the directory or directories
if (update.directory) {
dockerRunner.arg(["-e", `DEPENDABOT_DIRECTORY=${update.directory}`]);
}
if (update.directories && update.directories.length > 0) {
dockerRunner.arg(["-e", `DEPENDABOT_DIRECTORIES=${JSON.stringify(update.directories)}`]);
}

// Set the target branch
if (update.targetBranch) {
Expand All @@ -83,6 +91,11 @@ async function run() {
dockerRunner.arg(["-e", `DEPENDABOT_MILESTONE=${update.milestone}`]);
}

// Set the PR branch prefix
if (variables.branchNamePrefix) {
dockerRunner.arg(["-e", `DEPENDABOT_BRANCH_NAME_PREFIX=${variables.branchNamePrefix}`]);
}

// Set the PR branch separator
if (update.branchNameSeparator) {
dockerRunner.arg(["-e", `DEPENDABOT_BRANCH_NAME_SEPARATOR=${update.branchNameSeparator}`]);
Expand Down Expand Up @@ -111,6 +124,32 @@ async function run() {
dockerRunner.arg(["-e", `DEPENDABOT_IGNORE_CONDITIONS=${ignore}`]);
}

// Set the dependency groups
let groups = update.groups;
if (groups) {
dockerRunner.arg(["-e", `DEPENDABOT_DEPENDENCY_GROUPS=${groups}`]);
}

let prNamePrefixStyle = variables.prNamePrefixStyle;
if (prNamePrefixStyle) {
dockerRunner.arg(["-e", `DEPENDABOT_PR_NAME_PREFIX_STYLE=${prNamePrefixStyle}`]);
}

let prMessageHeader = variables.prMessageHeader;
if (prMessageHeader) {
dockerRunner.arg(["-e", `DEPENDABOT_MESSAGE_HEADER=${prMessageHeader}`]);
}

let prMessageFooter = variables.prMessageFooter;
if (prMessageFooter) {
dockerRunner.arg(["-e", `DEPENDABOT_MESSAGE_FOOTER=${prMessageFooter}`]);
}

let prCompatibilityScoreBadge = variables.prCompatibilityScoreBadge;
if (prCompatibilityScoreBadge) {
dockerRunner.arg(["-e", `DEPENDABOT_COMPATIBILITY_SCORE_BADGE=true`]);
}

// Set the commit message options
let commitMessage = update.commitMessage;
if (commitMessage) {
Expand Down Expand Up @@ -164,6 +203,11 @@ async function run() {
dockerRunner.arg(["-e", 'DEPENDABOT_SKIP_PULL_REQUESTS=true']);
}

// Set skip pull requests if true
if (variables.commentPullRequests === true) {
dockerRunner.arg(["-e", 'DEPENDABOT_COMMENT_PULL_REQUESTS=true']);
}

// Set abandon Unwanted pull requests if true
if (variables.abandonUnwantedPullRequests === true) {
dockerRunner.arg(["-e", 'DEPENDABOT_CLOSE_PULL_REQUESTS=true']);
Expand All @@ -176,6 +220,11 @@ async function run() {
dockerRunner.arg(["-e", `DEPENDABOT_SECURITY_ADVISORIES_FILE=${containerPath}`]);
}

let securityUpdatesOnly = variables.securityUpdatesOnly;
if (securityUpdatesOnly) {
dockerRunner.arg(["-e", `DEPENDABOT_SECURITY_UPDATES_ONLY=true`]);
}

/*
* Set env variables in the runner for Azure
*/
Expand Down Expand Up @@ -230,6 +279,11 @@ async function run() {
}
}

// Set debug
if (variables.debug === true) {
dockerRunner.arg(["-e", 'DEPENDABOT_DEBUG=true']);
}

// Add in extra environment variables
variables.extraEnvironmentVariables.forEach(extraEnvVar => {
dockerRunner.arg(["-e", extraEnvVar]);
Expand All @@ -247,7 +301,7 @@ async function run() {
dockerRunner.arg(dockerImage);

// set the script to be run
dockerRunner.arg('update_script');
dockerRunner.arg(variables.command);

// Now execute using docker
await dockerRunner.exec();
Expand Down
Loading