Skip to content

Commit 55e74d7

Browse files
authored
Update java.yaml
1 parent a248601 commit 55e74d7

File tree

1 file changed

+7
-40
lines changed

1 file changed

+7
-40
lines changed

.github/workflows/java.yaml

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,50 +10,17 @@ on:
1010

1111
jobs:
1212
check-copyright:
13-
name: Check Copyright
1413
runs-on: ubuntu-latest
14+
name: Check Copyright
1515
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
5419
with:
20+
directory: './cics-java-liberty-link-app/'
21+
file-extensions: '*.java'
22+
base-copyright: 'Copyright IBM Corp. 2025'
5523
token: ${{ secrets.GITHUB_TOKEN }}
56-
base: ${{ github.head_ref }}
5724

5825
build-mvnw:
5926
name: Build Maven Wrapper

0 commit comments

Comments
 (0)