Explain misconfigured workflow (#405)

Fixes #136
This commit is contained in:
Josh Soref
2023-06-19 07:07:00 -04:00
committed by GitHub
parent fe87e601ad
commit b5ff161cf0
3 changed files with 41 additions and 10 deletions

22
dist/index.js vendored
View File

@@ -76,11 +76,25 @@ function run() {
labelsToRemove.push(label);
}
}
if (labels.length > 0) {
yield addLabels(client, prNumber, labels);
try {
if (labels.length > 0) {
yield addLabels(client, prNumber, labels);
}
if (syncLabels && labelsToRemove.length) {
yield removeLabels(client, prNumber, labelsToRemove);
}
}
if (syncLabels && labelsToRemove.length) {
yield removeLabels(client, prNumber, labelsToRemove);
catch (error) {
if (error.name === 'HttpError' &&
error.message === 'Resource not accessible by integration') {
core.warning(`The action requires write permission to add labels to pull requests. For more information please refer to the action documentation: https://github.com/actions/labeler#permissions`, {
title: `${process.env['GITHUB_ACTION_REPOSITORY']} running under '${github.context.eventName}' is misconfigured`
});
core.setFailed(error.message);
}
else {
throw error;
}
}
}
catch (error) {