Skip to content

Commit

Permalink
chore:Worflow to find delete statement in sql file
Browse files Browse the repository at this point in the history
  • Loading branch information
rnithinpaladin committed Feb 5, 2024
1 parent 09ae6f4 commit 3b1450f
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/mysqldeletecheck.yml
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.'
})

0 comments on commit 3b1450f

Please sign in to comment.