Skip to content

Commit

Permalink
Merge pull request #4 from sprucehealth/jon/set-output
Browse files Browse the repository at this point in the history
set outputs (didSetStatus and statusFieldValue)
  • Loading branch information
sibljon authored Sep 13, 2024
2 parents 93424d5 + f0b9332 commit af82229
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 39 deletions.
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ inputs:
required: false
description: 'If specified, the PR will be labeled with this value when the status is updated to the value of `statusFieldValueWhenPRReadyForReviewIsApproved`.'
default: ''
outputs:
didSetStatus:
description: 'true if the status was set, false or undefined if not set'
statusFieldValue:
description: 'the value of the status field that was set, or undefined if not set'
runs:
using: 'node20'
main: 'dist/index.js'
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

32 changes: 13 additions & 19 deletions dist/main.js

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

33 changes: 14 additions & 19 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 @@ -189,12 +191,7 @@ export async function run(): Promise<void> {
skipSettingStatusForPRReadyForReviewIsApprovedIfLabeledWith.length > 0 &&
!hasSkipSettingStatusForPRApprovedLabel
) {
await setStatusFieldvalueForAsanaTask({
fieldValue: statusFieldValueWhenPRReadyForReviewIsApproved,
taskID,
client,
statusCustomField,
});
fieldValue = statusFieldValueWhenPRReadyForReviewIsApproved;
}
if (labelToApplyToPRWhenApproved) {
await octokit.issues.addLabels({
Expand All @@ -205,32 +202,30 @@ export async function run(): Promise<void> {
});
}
} else if (pr?.draft && statusFieldValueWhenDraftPRIsOpen) {
await setStatusFieldvalueForAsanaTask({
fieldValue: statusFieldValueWhenDraftPRIsOpen,
taskID,
client,
statusCustomField,
});
fieldValue = statusFieldValueWhenDraftPRIsOpen;
} else if (statusFieldValueWhenPRReadyForReviewIsOpen) {
await setStatusFieldvalueForAsanaTask({
fieldValue: statusFieldValueWhenPRReadyForReviewIsOpen,
taskID,
client,
statusCustomField,
});
fieldValue = statusFieldValueWhenPRReadyForReviewIsOpen;
}
} else if (
// this is expected to run on pushes to `main` (aka a merged pull request)
triggerIsPushToMain &&
statusFieldValueForMergedCommitToMain
) {
core.info(`🔍 triggerIsPushToMain`);
fieldValue = statusFieldValueForMergedCommitToMain;
}

if (fieldValue) {
await setStatusFieldvalueForAsanaTask({
fieldValue: statusFieldValueForMergedCommitToMain,
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 af82229

Please sign in to comment.