Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changes/8da6963b-713e-41fa-b8ff-6ea18629118b.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "8da6963b-713e-41fa-b8ff-6ea18629118b",
"type": "bugfix",
"description": "fixed a foo",
"issues": [
"awslabs/aws-sdk-kotlin#1714"
]
}
8 changes: 8 additions & 0 deletions .changes/f3bee672-bc64-4103-adad-5f6db9e139a6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "f3bee672-bc64-4103-adad-5f6db9e139a6",
"type": "bugfix",
"description": "fixed a foo",
"issues": [
"awslabs/aws-sdk-kotlin#2000"
]
}
92 changes: 92 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
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: |
# Get the previous tag
PREVIOUS_TAG=$(git tag --sort=-version:refname | sed -n '5p')
CURRENT_TAG=$(git tag --sort=-version:refname | sed -n '1p')

# Convert tag date to GitHub search format
TAG_DATE=$(git log -1 --format="%ci" "$PREVIOUS_TAG" | sed 's/ /T/' | sed 's/ +0000/Z/')
echo "Using tag date: $TAG_DATE"

# Find all PRs merged from the last release tag date
ALL_PRS=$(gh pr list \
--state open \
--json number,body,createdAt \
--jq '[.[] | select(.createdAt > "'$TAG_DATE'") | .number]'
)
echo "Found PRs: $ALL_PRS"

# Find all issue number from PRs merged into release branch
ISSUE_NUMBERS=""
for pr_number in $(echo "$ALL_PRS" | jq -r '.[]'); do

# Get the merge commit SHA for this PR
MERGE_COMMIT=$(gh pr view "$pr_number" --json mergeCommit --jq '.mergeCommit.oid')
echo " PR $pr_number merge commit: $MERGE_COMMIT"

# Check if this commit exists in the release branch
if git merge-base --is-ancestor "$MERGE_COMMIT" origin/release 2>/dev/null; then
echo "PR $pr_number is in release branch"

# Get issue numbers from this PR
PR_ISSUES=$(gh pr view "$pr_number" --json body --jq '.body' | \
grep -o 'issues/[0-9]*' | \
sed 's/issues\///')
echo " Found issues: $PR_ISSUES"

ISSUE_NUMBERS="$ISSUE_NUMBERS $PR_ISSUES"
fi

# TESTING
# testing fetching issue number
# Get issue numbers from changelog entries in this PR
PR_ISSUES=$(gh pr view "$pr_number" --json files --jq '.files[].path' | \
grep '\.changes/.*\.json$' | \
xargs -I {} cat {} 2>/dev/null | \
jq -r '.issues[]?' 2>/dev/null | \
sed 's/.*#//')
echo " Found issues: $PR_ISSUES"
ISSUE_NUMBERS="$ISSUE_NUMBERS $PR_ISSUES"

done



# Comment on each issue found
FAILURES=""

while read -r issue_number; do
if [ -n "$issue_number" ]; then
echo "Commenting on issue #$issue_number"
if ! gh issue comment "$issue_number" --body "A [#$pr_number](https://github.com/${{ github.repository }}/pull/$pr_number) related to this issue was included in [**$CURRENT_TAG**](https://github.com/${{ github.repository }}/releases/tag/$CURRENT_TAG)."; then
echo "::error::Failed to comment on issue #$issue_number"
FAILURES="$FAILURES #$issue_number"
fi
fi
done < <(echo "$ISSUE_NUMBERS" | tr ' ' '\n')

if [ -n "$FAILURES" ]; then
echo "::error::Failed to update the following issue(s):$FAILURES"
exit 1
fi
Loading