weblate/.github/workflows/issue-commented.yml
renovate[bot] 4a05524be0
chore(deps): update actions/github-script action to v9 (#18890)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-04-10 02:53:16 +00:00

73 lines
2.5 KiB
YAML

# Copyright © Michal Čihař <michal@weblate.org>
#
# SPDX-License-Identifier: CC0-1.0
#
# Issue lifecycle: Add "Waiting for: Triage" label when "Waiting for: Community" was commented
name: 'Issues: Add triage label on comment'
on:
issue_comment:
types: [created]
permissions:
issues: write
jobs:
apply-label:
runs-on: ubuntu-slim
if: |
! github.event.issue.pull_request &&
contains(github.event.issue.labels.*.name, 'Waiting for: Community') &&
github.event.sender.type != 'Bot' &&
github.event.sender.login != 'github-actions' &&
github.event.sender.login != 'weblate' &&
! endsWith(github.event.sender.login, '[bot]') &&
! endsWith(github.event.sender.login, 'bot')
steps:
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
var is_member = false;
const org = 'WeblateOrg';
const username = context.payload.sender.login;
try {
const response = await github.rest.orgs.checkMembershipForUser({
org: org,
username: username,
});
is_member = (response.status == 204);
} catch (error) {
console.log(
`Failed requesting GitHub organization "${org}" membership status of user "${username}": ${error.message}`,
);
is_member = false;
}
if (is_member) {
console.log(`User ${context.payload.sender.login} is member of WeblateOrg, skipping state update`);
} else {
const labels = await github.rest.issues.listLabelsOnIssue({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
for (const label of labels.data) {
if (label.name.startsWith('Waiting for: ')) {
console.log(`Removing label ${label.name}`);
await github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: label.name,
})
}
}
if (context.payload.issue.state == 'open') {
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['Waiting for: Triage']
})
}
}