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

Add pre-commit script and job for syncing scripts to ansible playbooks #7

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
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
36 changes: 36 additions & 0 deletions .github/workflows/check-scripts-updates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Check Script and Playbook Updates

on:
pull_request:
paths:
- 'scripts/**'

jobs:
check-updates:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check if scripts/ were updated without corresponding updates in playbooks/
run: |
BASE_COMMIT=${{ github.event.pull_request.base.sha }}
HEAD_COMMIT=${{ github.event.pull_request.head.sha }}

changed_files=$(git diff --name-only "$BASE_COMMIT" "$HEAD_COMMIT")

# Check if any files in scripts/ were updated (excluding wrap_scripts_in_yaml.py)
scripts_updated=$(echo "$changed_files" | grep -v 'wrap_scripts_in_yaml.py' | grep 'scripts/' || true)
echo "Scripts updated: $scripts_updated"

# Check if any files in playbooks/ were updated
playbooks_updated=$(echo "$changed_files" | grep 'playbooks/' || true)
echo "Playbooks updated: $playbooks_updated"

if [[ -n "$scripts_updated" && -z "$playbooks_updated" ]]; then
echo "Files in scripts/ were updated without corresponding updates in playbooks/"
exit 1
fi

echo "Check passed"
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ repos:
"-sn", # Don't display the score
"--rcfile=.pylintrc", # Link to your config file
]
- id: wrap-scripts-in-yaml
name: wrap-scripts-in-yaml
entry: python scripts/wrap_scripts_in_yaml.py
language: python
files: scripts/.*\.py$


- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.0
Expand Down
Loading