Skip to content

Commit

Permalink
c
Browse files Browse the repository at this point in the history
  • Loading branch information
sibljon committed Sep 13, 2024
1 parent 4d34c5b commit f0b9332
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 47 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

29 changes: 7 additions & 22 deletions dist/main.js

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

32 changes: 8 additions & 24 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ export async function run(): Promise<void> {
continue;
}

let fieldValue = '';

if (
// this is expected to run upon PRs being opened or reopened
triggerIsPullRequest
Expand Down Expand Up @@ -184,19 +186,12 @@ export async function run(): Promise<void> {
`🔍 statusFieldValueWhenPRReadyForReviewIsApproved: ${statusFieldValueWhenPRReadyForReviewIsApproved}`
);

let fieldValue = '';
if (isApproved && isReadyForReview) {
if (
skipSettingStatusForPRReadyForReviewIsApprovedIfLabeledWith.length > 0 &&
!hasSkipSettingStatusForPRApprovedLabel
) {
fieldValue = statusFieldValueWhenPRReadyForReviewIsApproved;
await setStatusFieldvalueForAsanaTask({
fieldValue,
taskID,
client,
statusCustomField,
});
}
if (labelToApplyToPRWhenApproved) {
await octokit.issues.addLabels({
Expand All @@ -208,40 +203,29 @@ export async function run(): Promise<void> {
}
} else if (pr?.draft && statusFieldValueWhenDraftPRIsOpen) {
fieldValue = statusFieldValueWhenDraftPRIsOpen;
await setStatusFieldvalueForAsanaTask({
fieldValue,
taskID,
client,
statusCustomField,
});
} else if (statusFieldValueWhenPRReadyForReviewIsOpen) {
fieldValue = statusFieldValueWhenPRReadyForReviewIsOpen;
await setStatusFieldvalueForAsanaTask({
fieldValue,
taskID,
client,
statusCustomField,
});
}

core.setOutput('didSetStatus', 'true');
core.setOutput('statusFieldValue', fieldValue);
} else if (
// this is expected to run on pushes to `main` (aka a merged pull request)
triggerIsPushToMain &&
statusFieldValueForMergedCommitToMain
) {
core.info(`🔍 triggerIsPushToMain`);
let fieldValue = statusFieldValueForMergedCommitToMain;
fieldValue = statusFieldValueForMergedCommitToMain;
}

if (fieldValue) {
await setStatusFieldvalueForAsanaTask({
fieldValue,
taskID,
client,
statusCustomField,
});

core.setOutput('didSetStatus', 'true');
core.setOutput('statusFieldValue', fieldValue);
} else {
core.setOutput('didSetStatus', 'false');
}
}
} catch (error) {
Expand Down

0 comments on commit f0b9332

Please sign in to comment.