Skip to content

Commit

Permalink
ci: make sure all checked in files have SeatGeek copyright (#26)
Browse files Browse the repository at this point in the history
* add add-copyrights.sh script

* add check copyright header job to build workflow

* add nicer title here

* remove copyright in file to test workflow

* fix filename

* only show name of files that need to be updated

* tell user to run script if fails

* run add copyrights script
  • Loading branch information
zhammer authored Feb 12, 2024
1 parent 4100f42 commit 107c79c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ on:
branches:
- main
jobs:
check-copyright-header:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: scripts/add-copyrights.sh
- name: Check for changes
run: git diff --name-only --exit-code || (echo "Run scripts/add-copyrights.sh locally" && exit 1)
lint:
runs-on: ubuntu-latest
strategy:
Expand Down
22 changes: 22 additions & 0 deletions scripts/add-copyrights.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Define the copyright header
read -r -d '' COPYRIGHT_HEADER << EOM
/*
* Copyright SeatGeek
* Licensed under the terms of the Apache-2.0 license. See LICENSE file in project root for terms.
*/
EOM

# Loop over .ts and .tsx files in the plugins/ directory
for file in $(find plugins -type f \( -name "*.ts" -o -name "*.tsx" \)); do
# Check if the file is ignored by Git
if ! git check-ignore $file > /dev/null 2>&1; then
# If it's not ignored, check if the copyright header already exists in the file
if ! [[ "$(head -n4 $file)" == *"$COPYRIGHT_HEADER"* ]]; then
echo $file Δ
echo "${COPYRIGHT_HEADER}
$(cat $file)" > $file
fi
fi
done

0 comments on commit 107c79c

Please sign in to comment.