From c324d47d042ebb47d52c4507a91a700b54a21cd8 Mon Sep 17 00:00:00 2001 From: figeral Date: Tue, 2 Apr 2024 09:51:17 +0100 Subject: [PATCH] addition of a pull reqest workflow --- .../notify_on_pull_request_open.yaml | 34 +++++++++++++++++++ ..._pull_request.yaml => notify_on_push.yaml} | 6 ++-- src/notify_on_pull_request.py | 18 ++++++++++ src/notify_on_push.py | 4 +-- 4 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/notify_on_pull_request_open.yaml rename .github/workflows/{notify_on_pull_request.yaml => notify_on_push.yaml} (84%) create mode 100644 src/notify_on_pull_request.py diff --git a/.github/workflows/notify_on_pull_request_open.yaml b/.github/workflows/notify_on_pull_request_open.yaml new file mode 100644 index 0000000..7650ad9 --- /dev/null +++ b/.github/workflows/notify_on_pull_request_open.yaml @@ -0,0 +1,34 @@ +name: Pull Request workflow template Made for Gomu Developers OS Community +on: + pull_request: + branches: + -'*' +jobs: + rbuild_and_notify: + runs-on: ubuntu-latest + steps: + - name: checking out the repository + uses: actions/checkout@v3 + + - name: setting up python environment + uses: actions/setup-python@v5 + with: + python-version: '3.10' + cache: 'pip' + + - name: installing and caching dependencies + run: | + python3 -m pip install -r requirements.txt + + + - name: running Pull request Actions python script + env: + GOMU_BOT_TOKEN: ${{secrets.GOMU_BOT_TOKEN}} + GOMU_CHANEL_ID: ${{secrets.GOMU_CHANEL_ID}} + GITHUB_AUTHOR: ${{github.event.sender.login}} + GITHUB_REPOSITORY: ${{github.repository}} + GITHUB_PR_TITLE: ${{github.event.pull_request.title}} + GITHUB_PR_BODY: ${{github.event.pull_request.body}} + GITHUB_PR_LINK: ${{github.event.pull_request._links}} + run: | + python3 src/notify_on_pull_request.py \ No newline at end of file diff --git a/.github/workflows/notify_on_pull_request.yaml b/.github/workflows/notify_on_push.yaml similarity index 84% rename from .github/workflows/notify_on_pull_request.yaml rename to .github/workflows/notify_on_push.yaml index 6316b04..67f6a27 100644 --- a/.github/workflows/notify_on_pull_request.yaml +++ b/.github/workflows/notify_on_push.yaml @@ -1,4 +1,4 @@ -name: workflow template for Gomu Developers Community +name: Push workflow template Made for Gomu Developers OS Community on: push: @@ -23,13 +23,13 @@ jobs: python3 -m pip install -r requirements.txt - - name: running python script + - name: running Push Action python script env: GOMU_BOT_TOKEN: ${{secrets.GOMU_BOT_TOKEN}} GOMU_CHANEL_ID: ${{secrets.GOMU_CHANEL_ID}} GITHUB_AUTHOR: ${{github.event.sender.login}} GITHUB_REPOSITORY: ${{github.repository}} - GITHUB_PuSH_NUMBER: ${{github.event.commits.added}} + # GITHUB_PuSH_NUMBER: ${{github.event.commits.added}} GITHUB_COMMIT: ${{github.event.head_commit.message}} run: | python3 src/notify_on_push.py diff --git a/src/notify_on_pull_request.py b/src/notify_on_pull_request.py new file mode 100644 index 0000000..64b1d37 --- /dev/null +++ b/src/notify_on_pull_request.py @@ -0,0 +1,18 @@ +from bot import send_msg +import os +import time + + +def send_msg_on_PR(): + author = os.environ['GITHUB_AUTHOR'] + link = os.environ['GITHUB_PR_LINK'] + title = os.environ['GITHUB_PR_TITLE'] + body = os.environ['GITHUB_PR_BODY'] + + date = time.ctime() + text = f"📌 Pull Request effectué par {author} 🧠 \n Date: {date} \n \n Title :{title}\n Comments: {body[:25]} ... \n sentez vous libre l'examiné {link}" + send_msg(text) + + +if __name__ == '__main__': + send_msg_on_PR() diff --git a/src/notify_on_push.py b/src/notify_on_push.py index b3305ec..847eeba 100644 --- a/src/notify_on_push.py +++ b/src/notify_on_push.py @@ -8,9 +8,9 @@ def send_msg_on_push(): repository = os.environ['GITHUB_REPOSITORY'] link = f"https://github.com/{repository}" commits = os.environ['GITHUB_COMMIT'] - count = len(os.environ['GITHUB_PuSH_NUMBER']) + # count = len(os.environ['GITHUB_PuSH_NUMBER']) date = time.ctime() - text = f"📌 Push effectué par {author} 🧠 \n Date: {date} \n Commits: {commits[:25]} ... \n sentez vous libre l'examiné {link}" + text = f"📌 Push effectué par {author} 🧠 \n Date: {date} \n \n Commits: {commits[:25]} ... \n sentez vous libre l'examiné {link}" send_msg(text)