-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore:Worflow to find delete statement in sql file
- Loading branch information
1 parent
09ae6f4
commit 3b1450f
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Check SQL files for DELETE statements | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- '**.sql' | ||
|
||
jobs: | ||
check-sql: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # fetch the entire history | ||
|
||
- name: Check for DELETE statements in changed files | ||
id: check | ||
run: | | ||
FILES=$(git diff --name-only HEAD HEAD~1) | ||
for FILE in $FILES | ||
do | ||
if [[ $FILE == *.sql ]] | ||
then | ||
if grep -q 'DELETE' "$FILE" | ||
then | ||
echo "::set-output name=delete_found::true" | ||
break | ||
fi | ||
fi | ||
done | ||
- name: Comment on PR | ||
if: steps.check.outputs.delete_found == 'true' | ||
uses: actions/github-script@v5 | ||
with: | ||
script: | | ||
github.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: '⚠️ DELETE statement found in SQL files.' | ||
}) |