rmuir commented on code in PR #14927: URL: https://github.com/apache/lucene/pull/14927#discussion_r2194842953
########## .github/workflows/auto-format.yml: ########## @@ -0,0 +1,359 @@ +name: Lucene Auto Format Bot + +on: + issue_comment: + types: [created] + +env: + DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }} + +jobs: + format-check: + # Only run on pull requests when the bot is mentioned + if: | + github.event.issue.pull_request && + contains(github.event.comment.body, '/format-fix apply') + runs-on: ubuntu-latest + timeout-minutes: 30 + + permissions: + contents: write + pull-requests: write + issues: write + + steps: + - name: Check permissions + uses: actions/github-script@v7 + with: + script: | + const actorPermission = await github.rest.repos.getCollaboratorPermissionLevel({ + owner: context.repo.owner, + repo: context.repo.repo, + username: context.actor + }); + + const permission = actorPermission.data.permission; + const hasPermission = ['admin', 'write'].includes(permission); + + if (!hasPermission) { + core.setFailed(`User @${context.actor} does not have permission to run the format bot. Required: admin or write access.`); + return; + } + + - name: Add workflow started reaction + uses: actions/github-script@v7 + with: + script: | + await github.rest.reactions.createForIssueComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: context.payload.comment.id, + content: 'eyes' + }); + + - name: Get PR details + id: pr_details + uses: actions/github-script@v7 + with: + script: | + const prNumber = context.issue.number; + const { data: pr } = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber + }); + + return { + head_ref: pr.head.ref, + head_sha: pr.head.sha, + base_ref: pr.base.ref, + base_sha: pr.base.sha, + clone_url: pr.head.repo.clone_url, + ssh_url: pr.head.repo.ssh_url, + repo_full_name: pr.head.repo.full_name + }; + + - name: Checkout PR code + uses: actions/checkout@v4 + with: + repository: ${{ fromJson(steps.pr_details.outputs.result).repo_full_name }} + ref: ${{ fromJson(steps.pr_details.outputs.result).head_ref }} + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + - uses: ./.github/actions/prepare-for-build + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v46 Review Comment: This one needs to use a different action, one approved by apache. list: https://github.com/apache/infrastructure-actions/blob/main/actions.yml -- 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: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org