Files
herdrdev__herdr/.github/workflows/label-intends-to-pr.yml
dependabot[bot] c5e1a20ad3 chore(deps): bump the github-actions group with 7 updates (#184)
Bumps the github-actions group with 7 updates:

| Package | From | To |
| --- | --- | --- |
| [actions/checkout](https://github.com/actions/checkout) | `4` | `6` |
| [actions/github-script](https://github.com/actions/github-script) | `7` | `9` |
| [actions/upload-artifact](https://github.com/actions/upload-artifact) | `4` | `7` |
| [extractions/setup-just](https://github.com/extractions/setup-just) | `3` | `4` |
| [taiki-e/install-action](https://github.com/taiki-e/install-action) | `2.75.19` | `2.79.1` |
| [actions/download-artifact](https://github.com/actions/download-artifact) | `4` | `8` |
| [softprops/action-gh-release](https://github.com/softprops/action-gh-release) | `2` | `3` |


Updates `actions/checkout` from 4 to 6
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v6)

Updates `actions/github-script` from 7 to 9
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/v7...v9)

Updates `actions/upload-artifact` from 4 to 7
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v4...v7)

Updates `extractions/setup-just` from 3 to 4
- [Release notes](https://github.com/extractions/setup-just/releases)
- [Commits](https://github.com/extractions/setup-just/compare/v3...v4)

Updates `taiki-e/install-action` from 2.75.19 to 2.79.1
- [Release notes](https://github.com/taiki-e/install-action/releases)
- [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/taiki-e/install-action/compare/5f57d6cb7cd20b14a8a27f522884c4bc8a187458...b550161ef8a7bc4f2a671c0b03a18ac9ccedea1e)

Updates `actions/download-artifact` from 4 to 8
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v4...v8)

Updates `softprops/action-gh-release` from 2 to 3
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](https://github.com/softprops/action-gh-release/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/github-script
  dependency-version: '9'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/upload-artifact
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: extractions/setup-just
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: taiki-e/install-action
  dependency-version: 2.79.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: actions/download-artifact
  dependency-version: '8'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: softprops/action-gh-release
  dependency-version: '3'
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-19 04:58:27 +03:00

93 lines
3.0 KiB
YAML

name: Label contributor intent
on:
issues:
types: [opened, edited]
permissions:
issues: write
env:
INTENDS_TO_PR_LABEL: intends-to-pr
jobs:
label:
if: ${{ !github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
- name: Sync intends-to-pr label
uses: actions/github-script@v9
with:
script: |
const label = process.env.INTENDS_TO_PR_LABEL;
const body = context.payload.issue.body || '';
const issueNumber = context.payload.issue.number;
const { owner, repo } = context.repo;
const checkedIntentPattern = /^\s*-\s*\[[xX]\]\s*I intend to open a PR for this (?:change|issue)\.\s*$/m;
const uncheckedIntentPattern = /^\s*-\s*\[ \]\s*I intend to open a PR for this (?:change|issue)\.\s*$/m;
const cliIntentPattern = /^\s*\/i-intend-to-pr\s*$/m;
const shouldAddLabel = checkedIntentPattern.test(body) || cliIntentPattern.test(body);
const shouldRemoveLabel = uncheckedIntentPattern.test(body);
const labels = context.payload.issue.labels.map((item) =>
typeof item === 'string' ? item : item.name,
);
const hasLabel = labels.includes(label);
if (shouldAddLabel && hasLabel) {
console.log(`${label} is already present on #${issueNumber}.`);
return;
}
if (shouldRemoveLabel && !hasLabel) {
console.log(`${label} is already absent from #${issueNumber}.`);
return;
}
if (!shouldAddLabel && !shouldRemoveLabel) {
console.log(`No contribution intent signal found for #${issueNumber}.`);
return;
}
if (shouldAddLabel) {
try {
await github.rest.issues.getLabel({ owner, repo, name: label });
} catch (error) {
if (error.status !== 404) {
throw error;
}
await github.rest.issues.createLabel({
owner,
repo,
name: label,
color: '0E8A16',
description: 'Contributor intends to open a PR for this issue.',
});
}
await github.rest.issues.addLabels({
owner,
repo,
issue_number: issueNumber,
labels: [label],
});
console.log(`Added ${label} to #${issueNumber}.`);
return;
}
try {
await github.rest.issues.removeLabel({
owner,
repo,
issue_number: issueNumber,
name: label,
});
console.log(`Removed ${label} from #${issueNumber}.`);
} catch (error) {
if (error.status !== 404) {
throw error;
}
console.log(`${label} was already absent from #${issueNumber}.`);
}