Skip to content

Commit

Permalink
Add gitguardian, dependabot, auto-approve workflow and mergify config…
Browse files Browse the repository at this point in the history
…uration
  • Loading branch information
niklasstoffers committed Dec 12, 2023
1 parent 9dd4bf5 commit 1862777
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitguardian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: 2
verbose: true
secret:
ignored-detectors:
- Generic Password
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
target-branch: "dev"
schedule:
interval: daily
26 changes: 26 additions & 0 deletions .github/workflows/auto-approve.yml
Original file line number Diff line number Diff line change
@@ -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)'
})
20 changes: 20 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/gitguardian/ggshield
rev: v1.22.0
hooks:
- id: ggshield
language_version: python3
stages: [commit]
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<br>
<img src="https://img.shields.io/github/languages/top/niklasstoffers/gitlab-auto-approve?color=blueviolet" alt="top language">
<img src="https://sloc.xyz/github/niklasstoffers/gitlab-auto-approve" alt="total lines">
<a href="https://www.codefactor.io/repository/github/niklasstoffers/hainzdiscord"><img src="https://www.codefactor.io/repository/github/niklasstoffers/hainzdiscord/badge" alt="code quality" /></a>
</p>

**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/).
Expand Down
3 changes: 3 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 1862777

Please sign in to comment.