|
| 1 | +# |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | +# contributor license agreements. See the NOTICE file distributed with |
| 4 | +# this work for additional information regarding copyright ownership. |
| 5 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | +# (the "License"); you may not use this file except in compliance with |
| 7 | +# 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, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | + |
| 18 | +# Modified by Datazip Pvt. Ltd. in 2026 |
| 19 | +# Original work Copyright The Apache Software Foundation (ASF) |
| 20 | + |
| 21 | +name: Modification-Header-Check |
| 22 | + |
| 23 | +on: |
| 24 | + pull_request: |
| 25 | + branches: |
| 26 | + - "master" |
| 27 | + - "staging" |
| 28 | + |
| 29 | +jobs: |
| 30 | + modification-header-check: |
| 31 | + runs-on: ubuntu-latest |
| 32 | + |
| 33 | + steps: |
| 34 | + - name: Checkout code |
| 35 | + uses: actions/checkout@v4 |
| 36 | + with: |
| 37 | + fetch-depth: 0 |
| 38 | + |
| 39 | + - name: Check modifications header |
| 40 | + run: | |
| 41 | + echo "Checking modified files..." |
| 42 | +
|
| 43 | + BASE_BRANCH=${{ github.base_ref }} |
| 44 | + CHANGED_FILES=$(git diff --name-only origin/$BASE_BRANCH...HEAD) |
| 45 | + DATAZIP_MODIFICATION_YEAR_REGEX="Modified by Datazip Pvt\. Ltd\. in [0-9]{4}" |
| 46 | + ASF_ORIGINAL_WORK_NOTICE_REGEX="Original work Copyright The Apache Software Foundation \\(ASF\\)" |
| 47 | + NOT_MODIFIED_FILES="" |
| 48 | + for file in $CHANGED_FILES; do |
| 49 | + if [[ ! -f "$file" ]]; then |
| 50 | + continue |
| 51 | + fi |
| 52 | +
|
| 53 | + if ! head -40 "$file" | grep -q -E "$DATAZIP_MODIFICATION_YEAR_REGEX" || ! head -40 "$file" | grep -q -E "$ASF_ORIGINAL_WORK_NOTICE_REGEX"; then |
| 54 | + NOT_MODIFIED_FILES+="$file"$'\n' |
| 55 | + fi |
| 56 | + done |
| 57 | +
|
| 58 | + if [ -n "$NOT_MODIFIED_FILES" ]; then |
| 59 | + echo "::error::The following files are missing required modification headers:" |
| 60 | + echo "$NOT_MODIFIED_FILES" |
| 61 | + exit 1 |
| 62 | + fi |
| 63 | +
|
| 64 | + echo "All modified files have Modifications header" |
| 65 | + |
0 commit comments