|
10 | 10 |
|
11 | 11 | jobs: |
12 | 12 | check-copyright: |
13 | | - name: Check Copyright |
14 | 13 | runs-on: ubuntu-latest |
| 14 | + name: Check Copyright |
15 | 15 | steps: |
16 | | - - name: Checkout repository |
17 | | - uses: actions/checkout@v3 |
18 | | - with: |
19 | | - fetch-depth: 0 |
20 | | - |
21 | | - - name: Check Copyright |
22 | | - env: |
23 | | - EXTENSIONS: "*.java" |
24 | | - BASE_COPYRIGHT: "Copyright IBM Corp. 2016" |
25 | | - run: | |
26 | | - for ext in "$EXTENSIONS"; do |
27 | | - for file in $(find . -type f -name "$ext" -path "./cics-java-liberty-link-app/*"); do |
28 | | - echo "Processing file: $file" |
29 | | - |
30 | | - LAST_MODIFIED_YEAR=$(git log --follow -1 --format="%ad" --date=format:"%Y" -- "$file") |
31 | | -
|
32 | | - if ! grep -q "Copyright" "$file"; then |
33 | | - echo -e "/**\n * $BASE_COPYRIGHT\n */\n$(cat "$file")" > "$file" |
34 | | - else |
35 | | - # Extract existing copyright line |
36 | | - CURRENT_COPYRIGHT=$(grep -o "Copyright IBM Corp. [0-9]\{4\}\(, [0-9]\{4\}\)\?" "$file") |
37 | | - |
38 | | - # Check if LAST_MODIFIED_YEAR is anywhere in current copyright |
39 | | - if [[ "$CURRENT_COPYRIGHT" != *"$LAST_MODIFIED_YEAR"* ]]; then |
40 | | - # Check if copyright has two years |
41 | | - if [[ "$CURRENT_COPYRIGHT" =~ ,\ [0-9]{4}$ ]]; then |
42 | | - # If there is already a second year, replace it |
43 | | - sed -i "s/$BASE_COPYRIGHT, [0-9]\{4\}/$BASE_COPYRIGHT, $LAST_MODIFIED_YEAR/" "$file" |
44 | | - else |
45 | | - # If there is no second year, add it |
46 | | - sed -i "s/$BASE_COPYRIGHT/$BASE_COPYRIGHT, $LAST_MODIFIED_YEAR/" "$file" |
47 | | - fi |
48 | | - fi |
49 | | - fi |
50 | | - done |
51 | | - done |
52 | | - - name: Create Pull Request |
53 | | - uses: peter-evans/create-pull-request@v7 |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + - id: copyright-action |
| 18 | + uses: cicsdev/.github/.github/actions/samples-copyright-checker@139edd8dc23af7f4f7dd9afe4d56a1053fe426a7 |
54 | 19 | with: |
| 20 | + directory: './cics-java-liberty-link-app/' |
| 21 | + file-extensions: '*.java' |
| 22 | + base-copyright: 'Copyright IBM Corp. 2025' |
55 | 23 | token: ${{ secrets.GITHUB_TOKEN }} |
56 | | - base: ${{ github.head_ref }} |
57 | 24 |
|
58 | 25 | build-mvnw: |
59 | 26 | name: Build Maven Wrapper |
|
0 commit comments