diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 00000000..d91ed5ae --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,19 @@ +name: PR + +on: + pull_request: + types: [edited, opened, reopened, synchronize] + +jobs: + title: + runs-on: ubuntu-latest + + name: Check PR title + + steps: + - name: Set up uv + uses: astral-sh/setup-uv@v6 + + - name: Check PR title + run: | + uvx --from=commitizen cz check --message "${{ github.event.pull_request.title }}" diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 91428943..7523c3b5 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -4,6 +4,7 @@ # Read Cookiecutter configuration. project_name = "{{ cookiecutter.__project_name_snake_case }}" development_environment = "{{ cookiecutter.development_environment }}" +with_conventional_commits = int("{{ cookiecutter.with_conventional_commits }}") with_fastapi_api = int("{{ cookiecutter.with_fastapi_api }}") with_typer_cli = int("{{ cookiecutter.with_typer_cli }}") continuous_integration = "{{ cookiecutter.continuous_integration }}" @@ -36,3 +37,5 @@ os.remove(".github/workflows/publish.yml") else: os.remove(".github/workflows/deploy.yml") + if not with_conventional_commits: + os.remove(".github/workflows/pr.yml") diff --git a/template/{% if ci == 'github' %}.github{% endif %}/workflows/{% if with_conventional_commits %}pr.yml{% endif %}.jinja b/template/{% if ci == 'github' %}.github{% endif %}/workflows/{% if with_conventional_commits %}pr.yml{% endif %}.jinja new file mode 100644 index 00000000..119fe789 --- /dev/null +++ b/template/{% if ci == 'github' %}.github{% endif %}/workflows/{% if with_conventional_commits %}pr.yml{% endif %}.jinja @@ -0,0 +1,19 @@ +name: PR + +on: + pull_request: + types: [edited, opened, reopened, synchronize] + +jobs: + title: + runs-on: ubuntu-latest + + name: Check PR title + + steps: + - name: Set up uv + uses: astral-sh/setup-uv@v6 + + - name: Check PR title + run: | + uvx --from=commitizen cz check --message "{% raw %}${{ github.event.pull_request.title }}{% endraw %}" diff --git a/{{ cookiecutter.__project_name_kebab_case }}/.github/workflows/pr.yml b/{{ cookiecutter.__project_name_kebab_case }}/.github/workflows/pr.yml new file mode 100644 index 00000000..119fe789 --- /dev/null +++ b/{{ cookiecutter.__project_name_kebab_case }}/.github/workflows/pr.yml @@ -0,0 +1,19 @@ +name: PR + +on: + pull_request: + types: [edited, opened, reopened, synchronize] + +jobs: + title: + runs-on: ubuntu-latest + + name: Check PR title + + steps: + - name: Set up uv + uses: astral-sh/setup-uv@v6 + + - name: Check PR title + run: | + uvx --from=commitizen cz check --message "{% raw %}${{ github.event.pull_request.title }}{% endraw %}"