[TEST] auto notify workflow #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: test.yml | |
| on: | |
| pull_request: | |
| types: [ opened, synchronize, reopened, labeled, unlabeled ] | |
| branches: | |
| - main | |
| - '*-main' | |
| permissions: | |
| issues: write | |
| jobs: | |
| auto_comment: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Comment on PRs with issue numbers | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| PREVIOUS_TAG=$(git describe --tags --abbrev=0) | |
| TAG_DATE=$(git log -1 --format="%ci" "$PREVIOUS_TAG" | sed 's/ /T/' | sed 's/ +0000/Z/') | |
| echo "Using tag date: $TAG_DATE" | |
| ISSUE_NUMBERS=$(gh pr list --search "is:pr is:open created:>=$TAG_DATE" --json number,body --jq '.[] | select(.body != null and (.body | test("issues/\\d+"))) | [.body | scan("issues/(\\d+)"; "g")] | .[]' | sort -u) | |
| if [ -z "$ISSUE_NUMBERS" ]; then | |
| echo "No issues found in recent PRs" | |
| exit 0 | |
| fi | |
| echo "Found issues: $ISSUE_NUMBERS" | |
| for issue_number in $ISSUE_NUMBERS; do | |
| echo "Commenting on issue #$issue_number" | |
| gh issue comment "$issue_number" --body "This issue was resolved and included in the latest release." | |
| done |