mumrah commented on code in PR #17290: URL: https://github.com/apache/kafka/pull/17290#discussion_r1777800075
########## .github/workflows/ci-requested.yml: ########## @@ -0,0 +1,89 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: CI Requested + +on: + workflow_run: + workflows: [CI] + types: + - requested + +jobs: + check-pr-labels: + # Even though job conditionals are difficult to debug, this will reduce the number of unnecessary runs + if: | + github.event_name == 'workflow_run' && + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.status == 'completed' && + github.event.workflow_run.conclusion == 'action_required' + runs-on: ubuntu-latest + steps: + - name: Env + run: printenv + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + - name: Checkout code + uses: actions/checkout@v4 + with: + persist-credentials: + false + - name: Check PR Labels + id: check-pr-labels + if: | + github.event_name == 'workflow_run' && + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.status == 'completed' && + github.event.workflow_run.conclusion == 'action_required' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + RUN_ID: ${{ github.event.workflow_run.id }} + HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} + HEAD_REPO: ${{ github.event.workflow_run.head_repository.owner.login }} + # Caution! This is a bit hacky. The GH documentation shows that the workflow_run event should include a list Review Comment: I think this might cause a race between the PR getting updated and the CI workflow being requested. By using "workflow_run" action "requested", we ensure the pending workflow exists. -- 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]
