diff --git a/.github/scripts/license_generator.py b/.github/scripts/license_generator.py new file mode 100644 index 00000000..703be84f --- /dev/null +++ b/.github/scripts/license_generator.py @@ -0,0 +1,18 @@ +from glob import glob + +pincer_license = """# Copyright Pincer 2021-Present +# Full MIT License can be found in `LICENSE` at the project root. + +""" + + +for file in glob("./pincer/**/*.py", recursive=True): + if file == "./pincer/__init__.py": + continue + + with open(file, "r+") as f: + lines = f.readlines() + if not lines[0].startswith("# Copyright Pincer 2021-Present\n"): + lines.insert(0, pincer_license) + f.seek(0) + f.writelines(lines) diff --git a/.github/workflows/sort_alls.yaml b/.github/workflows/run_scripts.yml similarity index 52% rename from .github/workflows/sort_alls.yaml rename to .github/workflows/run_scripts.yml index 404edaae..6491d91f 100644 --- a/.github/workflows/sort_alls.yaml +++ b/.github/workflows/run_scripts.yml @@ -1,4 +1,4 @@ -name: Sort Alls +name: Run Scripts on: push @@ -16,17 +16,19 @@ jobs: python-version: '3.8' architecture: 'x64' - - name: running script - run: python ./.github/scripts/all_sorter.py - - name: setup git run: | git config user.name "GitHub Actions" git config user.email "actions@pincer.dev" + git pull - - name: add to git + - name: running all sorter run: | - git pull - git add . - git diff-index --quiet HEAD || git commit -m ":art: Automatic `__all__` sorting" - git push + python ./.github/scripts/all_sorter.py + git diff-index --quiet HEAD || git commit -am ":art: Automatic `__all__` sorting" + + + - name: running license generator + run: | + python ./.github/scripts/license_generator.py + git diff-index --quiet HEAD || git commit -am ":page_facing_up: Automatic license generator"