diff --git a/.github/actions/core-cicd/deployment/deploy-docker/action.yml b/.github/actions/core-cicd/deployment/deploy-docker/action.yml index b234e60de0b7..b95993b8a451 100644 --- a/.github/actions/core-cicd/deployment/deploy-docker/action.yml +++ b/.github/actions/core-cicd/deployment/deploy-docker/action.yml @@ -146,7 +146,7 @@ runs: if: (inputs.docker_registry == 'GHCR.IO' || inputs.docker_registry == 'BOTH') && inputs.do_deploy == 'true' - name: Set up QEMU - uses: docker/setup-qemu-action@v3.0.0 + uses: docker/setup-qemu-action@v3.6.0 with: image: tonistiigi/binfmt:qemu-v7.0.0-28 platforms: ${{ inputs.docker_platforms }} @@ -174,14 +174,12 @@ runs: if: success() - name: Docker Setup Buildx - uses: docker/setup-buildx-action@v3.0.0 + uses: docker/setup-buildx-action@v3.10.0 with: - version: latest + version: v0.20.0 # version of buildx https://github.com/docker/buildx/releases platforms: ${{ inputs.docker_platforms }} - driver-opts: | - image=moby/buildkit:v0.12.2 - name: Build/Push Docker Image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6.15.0 with: context: ${{ steps.setup-context.outputs.docker_context }} tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/cicd_manual_build-docker-context.yml b/.github/workflows/cicd_manual_build-docker-context.yml index a4214d7819af..f2431392e502 100644 --- a/.github/workflows/cicd_manual_build-docker-context.yml +++ b/.github/workflows/cicd_manual_build-docker-context.yml @@ -33,17 +33,16 @@ jobs: echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV - name: Set up QEMU - uses: docker/setup-qemu-action@v3.0.0 + uses: docker/setup-qemu-action@v3.6.0 with: platforms: amd64,arm64 if: github.event.inputs.multi_arch == 'true' - id: docker-setup-buildx name: Docker Setup Buildx - uses: docker/setup-buildx-action@v3.0.0 + uses: docker/setup-buildx-action@v3.10.0 with: + version: v0.20.0 # version of buildx https://github.com/docker/buildx/releases platforms: ${{ env.PLATFORMS }} - driver-opts: | - image=moby/buildkit:v0.12.2 if: github.event.inputs.multi_arch == 'true' - name: Docker Hub login uses: docker/login-action@v3.0.0 @@ -51,7 +50,7 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - name: Build and push - uses: docker/build-push-action@v5.0.0 + uses: docker/build-push-action@v6.15.0 with: context: ./docker/${{ github.event.inputs.context }} push: ${{ github.event.inputs.push }} diff --git a/.github/workflows/cicd_manual_build-java-base.yml b/.github/workflows/cicd_manual_build-java-base.yml index 0fb2d749554a..c43e44f2cf45 100644 --- a/.github/workflows/cicd_manual_build-java-base.yml +++ b/.github/workflows/cicd_manual_build-java-base.yml @@ -30,17 +30,16 @@ jobs: echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV - name: Set up QEMU - uses: docker/setup-qemu-action@v3.0.0 + uses: docker/setup-qemu-action@v3.6.0 with: platforms: amd64,arm64 if: github.event.inputs.multi_arch == 'true' - id: docker-setup-buildx name: Docker Setup Buildx - uses: docker/setup-buildx-action@v3.0.0 + uses: docker/setup-buildx-action@v3.10.0 with: + version: v0.20.0 # version of buildx https://github.com/docker/buildx/releases platforms: ${{ env.PLATFORMS }} - driver-opts: | - image=moby/buildkit:v0.12.2 if: github.event.inputs.multi_arch == 'true' - name: Docker Hub login uses: docker/login-action@v3.0.0 @@ -48,7 +47,7 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - name: Build and push - uses: docker/build-push-action@v5.0.0 + uses: docker/build-push-action@v6.15.0 with: context: ./docker/java-base push: ${{ github.event.inputs.push }} diff --git a/.github/workflows/issue_comp_link-issue-to-pr.yml b/.github/workflows/issue_comp_link-issue-to-pr.yml index 538b491bcebf..5debee6640dc 100644 --- a/.github/workflows/issue_comp_link-issue-to-pr.yml +++ b/.github/workflows/issue_comp_link-issue-to-pr.yml @@ -1,113 +1,215 @@ -name: Link Issue to PR +name: Link issue to PR on: workflow_call: inputs: pr_branch: - description: 'Pull Request branch' - type: string + description: 'PR branch name' required: true + type: string pr_url: - description: 'Pull Request URL' + description: 'PR URL' + required: true type: string + pr_title: + description: 'PR title' required: true - secrets: - CI_MACHINE_TOKEN: - description: 'CI machine token' + type: string + pr_body: + description: 'PR body' required: true - - workflow_dispatch: - inputs: - pr_branch: - description: 'Pull Request branch' type: string + pr_author: + description: 'PR author' required: true - pr_url: - description: 'Pull Request URL' type: string + pr_merged: + description: 'PR merged status' required: true - -env: - GH_TOKEN: ${{ secrets.CI_MACHINE_TOKEN }} - + type: string jobs: - add-issue-to-pr: - runs-on: ubuntu-${{ vars.UBUNTU_RUNNER_VERSION || '24.04' }} - + link-issue: + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ github.token }} + steps: - - run: echo 'GitHub context' + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Debug workflow inputs + run: | + echo "PR Branch: ${{ inputs.pr_branch }}" + echo "PR URL: ${{ inputs.pr_url }}" + echo "PR Title: ${{ inputs.pr_title }}" + echo "PR Body: ${{ inputs.pr_body }}" + echo "PR Author: ${{ inputs.pr_author }}" + echo "PR Merged: ${{ inputs.pr_merged }}" env: GITHUB_CONTEXT: ${{ toJson(github) }} + - name: Check if PR already has linked issues + id: check_existing_issues + run: | + pr_url="${{ inputs.pr_url }}" + pr_number=$(echo "$pr_url" | grep -o '[0-9]*$') + + # Get PR details + pr_details=$(curl -s \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ env.GH_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/${{ github.repository }}/pulls/$pr_number") + + # Check for issues linked via GitHub's Development section (timeline events) + timeline_events=$(curl -s \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ env.GH_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "https://api.github.com/repos/${{ github.repository }}/issues/$pr_number/timeline") + + # Look for connected/disconnected events that indicate manual linking + connected_issue=$(echo "$timeline_events" | jq -r '.[] | select(.event == "connected") | .source.issue.number' | head -1) + + if [[ -n "$connected_issue" && "$connected_issue" != "null" ]]; then + echo "Found manually linked issue via Development section: $connected_issue" + echo "has_linked_issues=true" >> "$GITHUB_OUTPUT" + echo "linked_issue_number=$connected_issue" >> "$GITHUB_OUTPUT" + echo "link_method=development_section" >> "$GITHUB_OUTPUT" + else + # Check if PR body contains issue references (fixes #123, closes #456, etc.) + pr_body=$(echo "$pr_details" | jq -r '.body // ""') + + # Extract issue numbers from PR body using various keywords + linked_issues=$(echo "$pr_body" | grep -oiE '(fixes?|closes?|resolves?)\s+#([0-9]+)' | grep -oE '[0-9]+' | head -1) + + if [[ -n "$linked_issues" ]]; then + echo "Found linked issue in PR body: $linked_issues" + echo "has_linked_issues=true" >> "$GITHUB_OUTPUT" + echo "linked_issue_number=$linked_issues" >> "$GITHUB_OUTPUT" + echo "link_method=pr_body" >> "$GITHUB_OUTPUT" + else + echo "No linked issues found in Development section or PR body" + echo "has_linked_issues=false" >> "$GITHUB_OUTPUT" + fi + fi + - name: Extract issue number from branch name id: extract_issue_number run: | branch_name="${{ inputs.pr_branch }}" + issue_number="" + + # Try multiple patterns to extract issue number (more flexible but specific) if [[ "$branch_name" =~ ^([0-9]+)- ]]; then issue_number="${BASH_REMATCH[1]}" + echo "Found issue number at start of branch: $issue_number" elif [[ "$branch_name" =~ ^issue-([0-9]+)- ]]; then issue_number="${BASH_REMATCH[1]}" + echo "Found issue number with 'issue-' prefix: $issue_number" + elif [[ "$branch_name" =~ issue-([0-9]+) ]]; then + issue_number="${BASH_REMATCH[1]}" + echo "Found issue number with 'issue-' anywhere in branch: $issue_number" else - echo "Branch name doesn't match the expected pattern" - exit 1 + echo "No issue number found in branch name: $branch_name" fi echo "issue_number=$issue_number" >> "$GITHUB_OUTPUT" + - name: Determine final issue number + id: determine_issue + run: | + # Priority: 1) Manually linked issues (Development section or PR body), 2) Branch name extraction + if [[ "${{ steps.check_existing_issues.outputs.has_linked_issues }}" == "true" ]]; then + final_issue_number="${{ steps.check_existing_issues.outputs.linked_issue_number }}" + link_method="${{ steps.check_existing_issues.outputs.link_method }}" + echo "Using manually linked issue: $final_issue_number (via $link_method)" + elif [[ -n "${{ steps.extract_issue_number.outputs.issue_number }}" ]]; then + final_issue_number="${{ steps.extract_issue_number.outputs.issue_number }}" + echo "Using issue from branch name: $final_issue_number" + else + echo "::error::No issue number found in Development section, PR body, or branch name" + echo "::error::Please link an issue using one of these methods:" + echo "::error::1. Link via GitHub UI: Go to PR → Development section → Link issue" + echo "::error::2. Add 'fixes #123' (or closes/resolves) to PR body, or" + echo "::error::3. Use branch naming like 'issue-123-feature' or '123-feature'" + exit 1 + fi + + echo "final_issue_number=$final_issue_number" >> "$GITHUB_OUTPUT" + - name: Get existing issue comments id: get_comments run: | - comments="$(\ - curl -s \ + comments=$(curl -s \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer ${{ env.GH_TOKEN }}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/${{ github.repository }}/issues/${{ steps.extract_issue_number.outputs.issue_number }}/comments \ - | jq -c . - )" + https://api.github.com/repos/${{ github.repository }}/issues/${{ steps.determine_issue.outputs.final_issue_number }}/comments \ + | jq -c .) - echo "comments=${comments}" >> "$GITHUB_OUTPUT" + echo "comments=$comments" >> "$GITHUB_OUTPUT" - - name: Check if PR comment exists + - name: Check if comment already exists id: check_comment - uses: actions/github-script@v7 - with: - script: | - const prUrl = '${{ inputs.pr_url }}'; - let prList = `PRs:\n- ${prUrl}`; - let existingCommentId = ''; - const comments = JSON.parse(${{ toJSON(steps.get_comments.outputs.comments) }}); + run: | + comments='${{ steps.get_comments.outputs.comments }}' + pr_url="${{ inputs.pr_url }}" + + # Check if our bot comment already exists + existing_comment=$(echo "$comments" | jq -r '.[] | select(.user.login == "github-actions[bot]" and (.body | contains("PRs linked to this issue"))) | .id' | head -1) + + if [[ -n "$existing_comment" && "$existing_comment" != "null" ]]; then + echo "Found existing comment: $existing_comment" + echo "existing_comment_id=$existing_comment" >> "$GITHUB_OUTPUT" + else + echo "No existing comment found" + echo "existing_comment_id=" >> "$GITHUB_OUTPUT" + fi + + # Get existing PR list from the comment if it exists + if [[ -n "$existing_comment" && "$existing_comment" != "null" ]]; then + existing_body=$(echo "$comments" | jq -r --arg id "$existing_comment" '.[] | select(.id == ($id | tonumber)) | .body') + pr_list=$(echo "$existing_body" | grep -o "- \[.*\](.*).*" | sort -u) - for(comment of comments) { - const commentBody = comment.body; - if (commentBody.startsWith('PRs:')) { - existingCommentId = comment.id; - prList = `${commentBody}\n- ${prUrl}`; - break; - } - } + # Check if current PR is already in the list + if echo "$pr_list" | grep -q "$pr_url"; then + echo "PR already exists in comment, using existing list" + echo "pr_list=$existing_body" >> "$GITHUB_OUTPUT" + else + # Add new PR to the list + new_pr_line="- [${{ inputs.pr_title }}](${{ inputs.pr_url }}) by @${{ inputs.pr_author }}" + if [[ "${{ inputs.pr_merged }}" == "true" ]]; then + new_pr_line="$new_pr_line ✅" + fi + + updated_list=$(echo -e "$pr_list\n$new_pr_line" | sort -u) + new_body="## PRs linked to this issue\n\n$updated_list" + echo "pr_list=$new_body" >> "$GITHUB_OUTPUT" + fi + else + # Create new PR list + new_pr_line="- [${{ inputs.pr_title }}](${{ inputs.pr_url }}) by @${{ inputs.pr_author }}" + if [[ "${{ inputs.pr_merged }}" == "true" ]]; then + new_pr_line="$new_pr_line ✅" + fi - core.setOutput('pr_list', prList); - core.setOutput('existing_comment_id', existingCommentId); - console.log(`pr_list: [${prList}]`); - console.log(`existing_comment_id: [${existingCommentId}]`); + new_body="## PRs linked to this issue\n\n$new_pr_line" + echo "pr_list=$new_body" >> "$GITHUB_OUTPUT" + fi - - name: Update or create comment + - name: Create new comment if: steps.check_comment.outputs.existing_comment_id == '' uses: peter-evans/create-or-update-comment@v4 with: - issue-number: ${{ steps.extract_issue_number.outputs.issue_number }} + issue-number: ${{ steps.determine_issue.outputs.final_issue_number }} body: ${{ steps.check_comment.outputs.pr_list }} - name: Update existing comment if: steps.check_comment.outputs.existing_comment_id != '' - uses: actions/github-script@v7 + uses: peter-evans/create-or-update-comment@v4 with: - script: | - const prs = ${{ toJSON(steps.check_comment.outputs.pr_list) }}.split('\n'); - await github.rest.issues.updateComment({ - owner: '${{ github.repository_owner }}', - repo: '${{ github.event.repository.name }}', - comment_id: ${{ steps.check_comment.outputs.existing_comment_id }}, - body: prs.join('\n') - }); + comment-id: ${{ steps.check_comment.outputs.existing_comment_id }} + body: ${{ steps.check_comment.outputs.pr_list }} \ No newline at end of file diff --git a/.github/workflows/issue_open-pr.yml b/.github/workflows/issue_open-pr.yml index 636551a9af71..0629d29595e1 100644 --- a/.github/workflows/issue_open-pr.yml +++ b/.github/workflows/issue_open-pr.yml @@ -11,5 +11,7 @@ jobs: with: pr_branch: ${{ github.head_ref }} pr_url: ${{ github.event.pull_request.html_url }} - secrets: - CI_MACHINE_TOKEN: ${{ secrets.CI_MACHINE_TOKEN }} + pr_title: ${{ github.event.pull_request.title }} + pr_body: ${{ github.event.pull_request.body }} + pr_author: ${{ github.event.pull_request.user.login }} + pr_merged: ${{ github.event.pull_request.merged }} diff --git a/.github/workflows/legacy-release_comp_maven-build-docker-image.yml b/.github/workflows/legacy-release_comp_maven-build-docker-image.yml index 039b1148d8d2..ee74c9eb910b 100644 --- a/.github/workflows/legacy-release_comp_maven-build-docker-image.yml +++ b/.github/workflows/legacy-release_comp_maven-build-docker-image.yml @@ -256,7 +256,7 @@ jobs: if: success() - name: Set up QEMU - uses: docker/setup-qemu-action@v3.0.0 + uses: docker/setup-qemu-action@v3.6.0 with: image: tonistiigi/binfmt:qemu-v7.0.0-28 platforms: ${{ inputs.docker_platforms }} @@ -264,16 +264,14 @@ jobs: - name: Docker Setup Buildx id: docker-setup-buildx - uses: docker/setup-buildx-action@v3.0.0 + uses: docker/setup-buildx-action@v3.10.0 with: - version: latest + version: v0.20.0 # version of buildx https://github.com/docker/buildx/releases platforms: ${{ inputs.docker_platforms }} - driver-opts: | - image=moby/buildkit:v0.12.2 if: success() - name: Build/Push Docker Image - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6.15.0 with: context: ${{ env.DOCKER_BUILD_CONTEXT }}/context tags: ${{ steps.meta.outputs.tags }} diff --git a/test-fork-issue.md b/test-fork-issue.md new file mode 100644 index 000000000000..a8cdace5b0c5 --- /dev/null +++ b/test-fork-issue.md @@ -0,0 +1,10 @@ +# Test Fork Issue #385 + +This branch `issue-385-test-fork-issue` tests the enhanced workflow with a real issue created on the fork repository. + +This should: +1. Extract issue #385 from branch name +2. Successfully create/update comment on fork issue #385 +3. Complete successfully without affecting parent repository + +Issue #385 is specifically created for testing the enhanced workflow on the fork. \ No newline at end of file diff --git a/test-real-issue.md b/test-real-issue.md new file mode 100644 index 000000000000..9db1856838df --- /dev/null +++ b/test-real-issue.md @@ -0,0 +1,10 @@ +# Test Real Issue #32703 + +This branch `issue-32703-test-real-issue` tests the enhanced workflow with a real issue that exists. + +This should: +1. Extract issue #32703 from branch name +2. Successfully create/update comment on the actual issue +3. Complete successfully + +Issue #32703 is the actual issue we're solving: "add-issue-to-pr needs to be more relaxed on branch naming" \ No newline at end of file diff --git a/test-workflow-fixed.md b/test-workflow-fixed.md new file mode 100644 index 000000000000..566492bb0c40 --- /dev/null +++ b/test-workflow-fixed.md @@ -0,0 +1,9 @@ +# Test Fixed Workflow + +This branch `issue-888-test-workflow-fixed` tests the enhanced workflow with the syntax fix applied. + +Expected behavior: +1. Extract issue number 888 from branch name +2. Successfully make API call to get issue comments +3. Attempt to create/update comment on issue #888 +4. Complete successfully (or fail gracefully if issue doesn't exist) \ No newline at end of file