|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +name: Check Labels Reusable |
| 19 | + |
| 20 | +on: |
| 21 | + workflow_call: |
| 22 | + inputs: |
| 23 | + parent-workflow: |
| 24 | + description: "The parent workflow filename (without .yml)" |
| 25 | + required: true |
| 26 | + type: string |
| 27 | + outputs: |
| 28 | + ci-extra-labels: |
| 29 | + description: "The extra CI labels" |
| 30 | + value: ${{ jobs.check-labels.outputs.ci-extra-labels }} |
| 31 | + force: |
| 32 | + description: "Whether to force running the jobs" |
| 33 | + value: ${{ jobs.check-labels.outputs.force }} |
| 34 | + |
| 35 | +jobs: |
| 36 | + check-labels: |
| 37 | + name: Check labels |
| 38 | + runs-on: ubuntu-latest |
| 39 | + timeout-minutes: 5 |
| 40 | + outputs: |
| 41 | + ci-extra-labels: ${{ steps.check.outputs.ci-extra-labels }} |
| 42 | + force: ${{ steps.check.outputs.force }} |
| 43 | + steps: |
| 44 | + - name: Checkout Arrow |
| 45 | + if: github.event_name == 'pull_request' |
| 46 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 47 | + - name: Check |
| 48 | + id: check |
| 49 | + env: |
| 50 | + GH_TOKEN: ${{ github.token }} |
| 51 | + run: | |
| 52 | + set -ex |
| 53 | + case "${GITHUB_EVENT_NAME}" in |
| 54 | + push|schedule|workflow_dispatch) |
| 55 | + echo "force=true" >> "${GITHUB_OUTPUT}" |
| 56 | + ;; |
| 57 | + pull_request) |
| 58 | + { |
| 59 | + echo "ci-extra-labels<<LABELS" |
| 60 | + gh pr view ${{ github.event.number }} \ |
| 61 | + --jq '[.labels[].name | select(startswith("CI: Extra"))]' \ |
| 62 | + --json labels \ |
| 63 | + --repo ${GITHUB_REPOSITORY} |
| 64 | + echo "LABELS" |
| 65 | + } >> "${GITHUB_OUTPUT}" |
| 66 | + git fetch origin ${GITHUB_BASE_REF} |
| 67 | + git diff --stat origin/${GITHUB_BASE_REF}.. |
| 68 | + if git diff --stat origin/${GITHUB_BASE_REF}.. | \ |
| 69 | + grep \ |
| 70 | + --fixed-strings ".github/workflows/${{ inputs.parent-workflow }}.yml" \ |
| 71 | + --quiet; then |
| 72 | + echo "force=true" >> "${GITHUB_OUTPUT}" |
| 73 | + fi |
| 74 | + ;; |
| 75 | + esac |
0 commit comments