diff --git a/.changes/8da6963b-713e-41fa-b8ff-6ea18629118b.json b/.changes/8da6963b-713e-41fa-b8ff-6ea18629118b.json new file mode 100644 index 00000000000..d114842a7eb --- /dev/null +++ b/.changes/8da6963b-713e-41fa-b8ff-6ea18629118b.json @@ -0,0 +1,8 @@ +{ + "id": "8da6963b-713e-41fa-b8ff-6ea18629118b", + "type": "bugfix", + "description": "fixed a foo", + "issues": [ + "awslabs/aws-sdk-kotlin#1714" + ] +} \ No newline at end of file diff --git a/.changes/f3bee672-bc64-4103-adad-5f6db9e139a6.json b/.changes/f3bee672-bc64-4103-adad-5f6db9e139a6.json new file mode 100644 index 00000000000..a3bdc05a5cc --- /dev/null +++ b/.changes/f3bee672-bc64-4103-adad-5f6db9e139a6.json @@ -0,0 +1,8 @@ +{ + "id": "f3bee672-bc64-4103-adad-5f6db9e139a6", + "type": "bugfix", + "description": "fixed a foo", + "issues": [ + "awslabs/aws-sdk-kotlin#2000" + ] +} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000000..7158cf00436 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 \ No newline at end of file