Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meta: github action to check pull request files for svn info #804

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/lint_for_svn.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: lint_for_svn_on_pr

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
find_svn_lines:
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v2

- name: Get list of changed files
id: changed-files
uses: tj-actions/changed-files@v34

- name: Generate and run script on changed files
run: |
# Generate the check_lines.sh script
cat << EOF > check_lines.sh
#!/bin/bash

# List of lines to check
lines_to_check=(
"DART \$Id\$"
" <next few lines under version control, do not edit>"
" \$URL\$"
" \$Revision\$"
" \$Date\$"
)

# Function to check if any of the lines are in the file
check_lines_in_file() {
local file=\$1
for line in "\${lines_to_check[@]}"; do
if grep -qF "\$line" "\$file"; then
echo "Found '\$line' in \$file"
return 0
fi
done
return 1
}

# Iterate over the changed files
found_files=()
for file in "\$@"; do
if [[ "\$file" == ".github/workflows/lint_for_svn.yml" ]]; then
continue
fi
if check_lines_in_file "\$file"; then
found_files+=("\$file")
fi
done

if [ \${#found_files[@]} -ne 0 ]; then
echo "The following files contain the specified lines:"
for file in "\${found_files[@]}"; do
echo "\$file"
done
exit 1
else
echo "No lines found in any of the changed files."
fi
EOF

# Make the script executable
chmod +x check_lines.sh

# Run the script on each changed file
./check_lines.sh ${{ steps.changed-files.outputs.all_changed_files }}
Loading