Skip to content

Commit

Permalink
🐛 Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
NoaSecond committed May 30, 2024
1 parent 749c452 commit a494b68
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/addCopyright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ jobs:
run: |
git add .
git commit -m ":construction_worker: Add copyright to files" || echo "No changes to commit"
git pull
git push origin main
1 change: 1 addition & 0 deletions .github/workflows/sitemap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ jobs:
git config --local user.name "GitHub Action"
git add sitemap.xml
git commit -m ":construction_worker: Update sitemap.xml" || true
git pull
git push origin main
24 changes: 17 additions & 7 deletions utils/addCopyright.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import os

# Configurations
comment = "\n\n# Développé avec ❤️ par : www.noasecond.com."
extensions = ('.php', '.js', '.html', '.yml', '.css', '.sql', '.py')
# Configurations des commentaires pour chaque type de fichier
comments = {
'.php': "\n\n// Développé avec ❤️ par : www.noasecond.com.",
'.js': "\n\n// Développé avec ❤️ par : www.noasecond.com.",
'.html': "\n\n<!-- Développé avec ❤️ par : www.noasecond.com. -->",
'.yml': "\n\n# Développé avec ❤️ par : www.noasecond.com.",
'.css': "\n\n/* Développé avec ❤️ par : www.noasecond.com. */",
'.sql': "\n\n-- Développé avec ❤️ par : www.noasecond.com.",
'.py': "\n\n# Développé avec ❤️ par : www.noasecond.com."
}
extensions = comments.keys()
exclude_dirs = ['PHPMailer-6.9.1', '.git', '.gitattributes', '.gitignore']
exclude_files = ['exclude_this_file.php']

Expand All @@ -15,7 +23,7 @@ def should_exclude(file_path):
return True
return False

def add_comment_to_file(file_path):
def add_comment_to_file(file_path, comment):
with open(file_path, 'r+') as file:
content = file.read()
if comment.strip() not in content:
Expand All @@ -26,8 +34,10 @@ def main():
# Exclude specified directories
dirs[:] = [d for d in dirs if d not in exclude_dirs]
for file in files:
if file.endswith(extensions) and not should_exclude(os.path.join(root, file)):
add_comment_to_file(os.path.join(root, file))
file_path = os.path.join(root, file)
if file.endswith(extensions) and not should_exclude(file_path):
ext = os.path.splitext(file)[1]
add_comment_to_file(file_path, comments[ext])

if __name__ == "__main__":
main()
main()

0 comments on commit a494b68

Please sign in to comment.