github-advanced-security[bot] commented on code in PR #14738:
URL: https://github.com/apache/lucene/pull/14738#discussion_r2869496847
##########
.github/workflows/backport.yml:
##########
@@ -0,0 +1,92 @@
+name: Backport PR
+
+on:
+ pull_request:
+ types: [closed]
+
+jobs:
+ prepare:
+ if: github.event.pull_request.merged == true
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ pull-requests: write
+ outputs:
+ dry_run: ${{ steps.plan.outputs.dry_run }}
+ has_targets: ${{ steps.plan.outputs.has_targets }}
+ targets: ${{ steps.plan.outputs.targets }}
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #
v6.0.2
+ with:
+ fetch-depth: 0
+ token: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Plan backports
+ id: plan
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ PR_MERGE_COMMIT_SHA: ${{ github.event.pull_request.merge_commit_sha
}}
+ BACKPORT_DRY_RUN: ${{ vars.BACKPORT_DRY_RUN || 'true' }}
+ run: ./.github/workflows/backport.sh
+
+ backport:
+ needs: prepare
+ if: needs.prepare.outputs.has_targets == 'true' &&
needs.prepare.outputs.dry_run != 'true'
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ pull-requests: write
+ strategy:
+ fail-fast: false
+ matrix:
+ include: ${{ fromJSON(needs.prepare.outputs.targets) }}
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #
v6.0.2
+ with:
+ fetch-depth: 0
+ token: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Cherry-pick with approved action
+ id: cherry_pick
+ continue-on-error: true
+ uses:
carloscastrojumo/github-cherry-pick-action@503773289f4a459069c832dc628826685b75b4b3
# v1.0.10
+ with:
+ token: ${{ secrets.GITHUB_TOKEN }}
+ branch: ${{ matrix.target }}
+ cherry-pick-branch: backport-${{ github.event.pull_request.number
}}-to-${{ matrix.target }}
+ title: '[Backport ${{ matrix.target }}] {old_title}'
+ body: |
+ ## 🔄 Automatic Backport
+
+ Backport of #{old_pull_request_id} to `${{ matrix.target }}`.
+
+ **Target:** `${{ matrix.target }}`
+ **Version:** `${{ matrix.version }}`
+ labels: |
+ backport
+ inherit_labels: 'false'
+
+ - name: Handle failed action backport
+ if: steps.cherry_pick.outcome != 'success'
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ run: |
+ body="❌ **Backport to \`${{ matrix.target }}\`
failed**"$'\n\n'"Automatic cherry-pick action failed for this target. Please
inspect workflow logs and backport manually if needed."
+ gh pr comment "$PR_NUMBER" --body "$body"
+ gh pr edit "$PR_NUMBER" --add-label "backport-failed" 2>/dev/null ||
true
+
+ dry-run-report:
+ needs: prepare
+ if: needs.prepare.outputs.has_targets == 'true' &&
needs.prepare.outputs.dry_run == 'true'
+ runs-on: ubuntu-latest
+ steps:
+ - name: Report dry-run targets
+ run: |
+ echo "Backport dry-run mode is enabled."
+ echo "Planned targets: ${{ needs.prepare.outputs.targets }}"
Review Comment:
## Workflow does not contain permissions
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN.
Consider setting an explicit permissions block, using the following as a
minimal starting point: {{}}
[Show more
details](https://github.com/apache/lucene/security/code-scanning/257)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]