Skip to content

Commit

Permalink
feat: add action to check bucket name
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurfg committed Apr 16, 2024
1 parent 165d65a commit fa4f260
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions .github/workflows/scripts/check_sql_files.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
import os
import json

def get_changed_files():
changed_files = []
with open(os.environ['GITHUB_EVENT_PATH'], 'r') as f:
event = json.load(f)
for file in event['pull_request']['files']:
if file['filename'].endswith('.sql'):
changed_files.append(file['filename'])
return changed_files

def check_sql_files():
changed_files = get_changed_files()
found_staging = False
for root, dirs, files in os.walk("."):
for file in files:
if file.endswith(".sql"):
with open(os.path.join(root, file), "r") as f:
lines = f.readlines()
for line in lines:
if "basedosdados-staging" in line:
found_staging = True
print(f"Found 'basedosdados-staging' in {os.path.join(root, file)}")
break
if found_staging:
break
if found_staging:
break
for file in changed_files:
with open(file, "r") as f:
lines = f.readlines()
for line in lines:
if "basedosdados-staging" in line:
found_staging = True
print(f"Found 'basedosdados-staging' in {file}")
break
if found_staging:
break

if found_staging:
exit(1)
Expand Down

0 comments on commit fa4f260

Please sign in to comment.