Clean up AI-created code
* use commit hash to select action * refine bot name * refine comment identification regexs * use AWAITING_LABEL env variable in a more conventional way
This commit is contained in:
parent
390515f9a8
commit
9097556023
20
.github/workflows/cla-label.yml
vendored
20
.github/workflows/cla-label.yml
vendored
@ -20,19 +20,19 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Sync "awaiting cla" label
|
- name: Sync "awaiting cla" label
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 #v9.0.0
|
||||||
env:
|
env:
|
||||||
AWAITING_LABEL: 'awaiting cla'
|
AWAITING_LABEL: 'awaiting cla'
|
||||||
# Bot login that posts the CLA comment. Common values:
|
# Bot login that posts the CLA comment. Common values:
|
||||||
# 'github-actions[bot]', 'CLAassistant', 'cla-assistant[bot]'
|
# 'github-actions[bot]', 'CLAassistant', 'cla-assistant[bot]'
|
||||||
CLA_BOT_LOGINS: 'CLAassistant,cla-assistant[bot],github-actions[bot]'
|
CLA_BOT_LOGINS: 'CLAassistant'
|
||||||
# Regex (case-insensitive) that matches an UNSIGNED CLA comment
|
# Regex (case-insensitive) that matches an UNSIGNED CLA comment
|
||||||
NOT_SIGNED_REGEX: 'have not signed|has not signed|please sign|we need.*sign|\[ \]'
|
NOT_SIGNED_REGEX: 'cla-assistant.io/pull/badge/not_signed'
|
||||||
# Regex (case-insensitive) that matches a SIGNED CLA comment
|
# Regex (case-insensitive) that matches a SIGNED CLA comment
|
||||||
SIGNED_REGEX: 'all committers have signed|all contributors have signed|has signed the cla|have signed the cla'
|
SIGNED_REGEX: 'cla-assistant.io/pull/badge/signed'
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const { AWAITING_LABEL } = process.env;
|
const awaitingLabel = process.env.AWAITING_LABEL;
|
||||||
const botLogins = process.env.CLA_BOT_LOGINS.split(',').map(s => s.trim().toLowerCase());
|
const botLogins = process.env.CLA_BOT_LOGINS.split(',').map(s => s.trim().toLowerCase());
|
||||||
const notSigned = new RegExp(process.env.NOT_SIGNED_REGEX, 'i');
|
const notSigned = new RegExp(process.env.NOT_SIGNED_REGEX, 'i');
|
||||||
const signed = new RegExp(process.env.SIGNED_REGEX, 'i');
|
const signed = new RegExp(process.env.SIGNED_REGEX, 'i');
|
||||||
@ -69,19 +69,19 @@ jobs:
|
|||||||
owner, repo, issue_number: prNumber,
|
owner, repo, issue_number: prNumber,
|
||||||
});
|
});
|
||||||
const hasLabel = issue.labels.some(l =>
|
const hasLabel = issue.labels.some(l =>
|
||||||
(typeof l === 'string' ? l : l.name) === AWAITING_LABEL
|
(typeof l === 'string' ? l : l.name) === awaitingLabel
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isSigned && hasLabel) {
|
if (isSigned && hasLabel) {
|
||||||
await github.rest.issues.removeLabel({
|
await github.rest.issues.removeLabel({
|
||||||
owner, repo, issue_number: prNumber, name: AWAITING_LABEL,
|
owner, repo, issue_number: prNumber, name: awaitingLabel,
|
||||||
}).catch(e => core.warning(`removeLabel failed: ${e.message}`));
|
}).catch(e => core.warning(`removeLabel failed: ${e.message}`));
|
||||||
core.info(`Removed "${AWAITING_LABEL}".`);
|
core.info(`Removed "${awaitingLabel}".`);
|
||||||
} else if (!isSigned && !hasLabel) {
|
} else if (!isSigned && !hasLabel) {
|
||||||
await github.rest.issues.addLabels({
|
await github.rest.issues.addLabels({
|
||||||
owner, repo, issue_number: prNumber, labels: [AWAITING_LABEL],
|
owner, repo, issue_number: prNumber, labels: [awaitingLabel],
|
||||||
});
|
});
|
||||||
core.info(`Added "${AWAITING_LABEL}".`);
|
core.info(`Added "${awaitingLabel}".`);
|
||||||
} else {
|
} else {
|
||||||
core.info('Label already in the correct state.');
|
core.info('Label already in the correct state.');
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user