Files
herdr/.github/workflows/label-next-release-issues.yml
T
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

124 lines
4.3 KiB
YAML

name: Close pending-release issues
on:
push:
branches: [master]
permissions:
contents: read
issues: write
env:
NEXT_RELEASE_LABEL: pending-release
jobs:
close:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false
- name: Close issues referenced by pushed commits
shell: bash
env:
GH_TOKEN: ${{ secrets.KANGAL_GITHUB_TOKEN }}
run: |
set -euo pipefail
echo "Using GitHub token for $(gh api user --jq .login)."
BEFORE="${{ github.event.before }}"
AFTER="${{ github.sha }}"
ZERO_SHA="0000000000000000000000000000000000000000"
if [ "$BEFORE" = "$ZERO_SHA" ]; then
RANGE_ARGS=(-1 "$AFTER")
echo "Scanning latest commit $AFTER for refs #<issue> lines."
else
RANGE_ARGS=("$BEFORE..$AFTER")
echo "Scanning pushed commits in $BEFORE..$AFTER for refs #<issue> lines."
fi
mapfile -t ISSUES < <(
git log --format=%b "${RANGE_ARGS[@]}" \
| perl -ne 'print "$1\n" if /^\s*refs\s+#([0-9]+)\s*$/i' \
| sort -nu
)
if [ "${#ISSUES[@]}" -eq 0 ]; then
echo "No issue refs found."
exit 0
fi
if ! gh api "repos/${GITHUB_REPOSITORY}/labels/${NEXT_RELEASE_LABEL}" >/dev/null 2>&1; then
gh api -X POST "repos/${GITHUB_REPOSITORY}/labels" \
-f name="$NEXT_RELEASE_LABEL" \
-f color="5319E7" \
-f description="Implemented on master and pending a published release." \
>/dev/null \
|| gh api "repos/${GITHUB_REPOSITORY}/labels/${NEXT_RELEASE_LABEL}" >/dev/null
fi
PENDING_COMMENT_MARKER="<!-- herdr:pending-release -->"
PENDING_COMMENT="${PENDING_COMMENT_MARKER}"$'\n'"Implemented on master and queued for the next release. This is not available in a published Herdr release yet."
issue_has_comment_marker() {
local issue="$1"
local marker="$2"
local comments
if ! comments="$(gh api --paginate "repos/${GITHUB_REPOSITORY}/issues/${issue}/comments?per_page=100" --jq '.[].body')"; then
echo "::warning::Could not read comments for issue #$issue."
return 2
fi
grep -F -- "$marker" >/dev/null <<<"$comments"
}
for issue in "${ISSUES[@]}"; do
echo "Checking #$issue"
if ! data="$(gh api "repos/${GITHUB_REPOSITORY}/issues/${issue}")"; then
echo "::warning::Could not read issue #$issue; skipping."
continue
fi
if jq -e 'has("pull_request")' <<<"$data" >/dev/null; then
echo "Skipping #$issue because it is a pull request."
continue
fi
if [ "$(jq -r '.state' <<<"$data")" != "open" ]; then
echo "Skipping #$issue because it is not open."
continue
fi
HAS_NEXT_RELEASE_LABEL="$(jq -r --arg label "$NEXT_RELEASE_LABEL" 'any(.labels[].name; . == $label)' <<<"$data")"
if [ "$HAS_NEXT_RELEASE_LABEL" != "true" ]; then
if ! gh issue edit "$issue" --repo "$GITHUB_REPOSITORY" --add-label "$NEXT_RELEASE_LABEL"; then
echo "::warning::Could not label issue #$issue."
continue
fi
fi
MARKER_STATUS=0
issue_has_comment_marker "$issue" "$PENDING_COMMENT_MARKER" || MARKER_STATUS="$?"
if [ "$MARKER_STATUS" -eq 2 ]; then
continue
fi
HAS_PENDING_COMMENT="false"
if [ "$MARKER_STATUS" -eq 0 ]; then
HAS_PENDING_COMMENT="true"
fi
if [ "$HAS_PENDING_COMMENT" = "true" ]; then
if ! gh issue close "$issue" --repo "$GITHUB_REPOSITORY" --reason completed; then
echo "::warning::Could not close issue #$issue."
continue
fi
elif ! gh issue close "$issue" --repo "$GITHUB_REPOSITORY" --reason completed --comment "$PENDING_COMMENT"; then
echo "::warning::Could not close issue #$issue."
continue
fi
done