diff --git a/.gitguardian.yaml b/.gitguardian.yaml new file mode 100644 index 0000000..0a93332 --- /dev/null +++ b/.gitguardian.yaml @@ -0,0 +1,5 @@ +version: 2 +verbose: true +secret: + ignored-detectors: + - Generic Password \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b3b0098 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: +- package-ecosystem: pip + directory: "/" + target-branch: "dev" + schedule: + interval: daily \ No newline at end of file diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml new file mode 100644 index 0000000..ce8bf70 --- /dev/null +++ b/.github/workflows/auto-approve.yml @@ -0,0 +1,26 @@ +name: Auto approve + +on: + issue_comment: + types: + - created + +jobs: + auto-approve: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/github-script@v7 + name: LGTM Auto Approve + if: github.actor_id == github.repository_owner_id && contains(github.event.comment.body, 'LGTM') + with: + script: | + github.rest.pulls.createReview({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number, + review_id: 1, + event: 'APPROVE', + body: '![lgtm](https://media2.giphy.com/media/NytMLKyiaIh6VH9SPm/giphy.gif?cid=ecf05e47d9ttw0m7xov7ez4kh01r3x84hrwzycd46ucfo0v8&ep=v1_gifs_search&rid=giphy.gif&ct=g)' + }) \ No newline at end of file diff --git a/.mergify.yml b/.mergify.yml new file mode 100644 index 0000000..9dfdb6a --- /dev/null +++ b/.mergify.yml @@ -0,0 +1,20 @@ +pull_request_rules: + - name: Automatic merge ⬇️ on self-approval ✔ + conditions: + - author=niklasstoffers + - "#approved-reviews-by>=1" + - check-success=build + - check-success=test + - base=main + actions: + merge: + method: merge + - name: Automatic merge ⬇️ on approval ✔ + conditions: + - "approved-reviews-by=[niklasstoffers]" + - check-success=build + - check-success=test + - base=main + actions: + merge: + method: merge \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..6fc17df --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,7 @@ +repos: + - repo: https://github.com/gitguardian/ggshield + rev: v1.22.0 + hooks: + - id: ggshield + language_version: python3 + stages: [commit] \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 0f0f023..3374b1e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM python:3.12 WORKDIR /app COPY ./src /app -RUN pip install -r /app/requirements.txt +RUN pip install --no-cache-dir -r /app/requirements.txt ENTRYPOINT ["python", "main.py"] \ No newline at end of file diff --git a/README.md b/README.md index 4a615d5..f866fda 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@
top language total lines + code quality

**Gitlab Auto Approve** is a [Gitlab](https://about.gitlab.com/) bot for automatically approving merge requests. It's built based on [FastAPI](https://fastapi.tiangolo.com/). diff --git a/src/config.py b/src/config.py index 8a802b9..489168c 100644 --- a/src/config.py +++ b/src/config.py @@ -44,6 +44,9 @@ def load_env(config: Config): config.approval.strict_match = environ.get('APPROVAL_STRICT_MATCH', config.approval.strict_match) config.approval.only_for_members = get_list_env('APPROVAL_ONLY_FOR_MEMBERS', config.approval.only_for_members) config.approval.message = environ.get('APPROVAL_MESSAGE', config.approval.message) + + if config.approval.message is not None and len(config.approval.message.strip()) == 0: + config.approval.message = None def load_config(filename: str = "config.yaml") -> Config: