Skip to content

Commit

Permalink
Merge pull request #2 from Figeral/master
Browse files Browse the repository at this point in the history
Pull request vers la branch dev
  • Loading branch information
Figeral authored Apr 2, 2024
2 parents 5a6bc6e + c324d47 commit 9f54575
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 0 deletions.
Empty file.
34 changes: 34 additions & 0 deletions .github/workflows/notify_on_pull_request_open.yaml
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions .github/workflows/notify_on_push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Push workflow template Made for Gomu Developers OS Community

on:
push:
branches: ['master','dev']


jobs:
build_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 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_COMMIT: ${{github.event.head_commit.message}}
run: |
python3 src/notify_on_push.py
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests
18 changes: 18 additions & 0 deletions src/bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

import requests
import os


def send_msg(msg: str):
token = os.environ['GOMU_BOT_TOKEN']
chanel_id = os.environ['GOMU_CHANEL_ID']

baseurl = "https://api.telegram.org"
url = f"{baseurl}/bot{token}/sendMessage"
payload = dict(chat_id=chanel_id, text=msg)

try:
requests.post(url=url, params=payload)
raise Exception()
except Exception as exc:
print(type(exc))
Empty file removed src/index.py
Empty file.
18 changes: 18 additions & 0 deletions src/notify_on_pull_request.py
Original file line number Diff line number Diff line change
@@ -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()
18 changes: 18 additions & 0 deletions src/notify_on_push.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from bot import send_msg
import os
import time


def send_msg_on_push():
author = os.environ['GITHUB_AUTHOR']
repository = os.environ['GITHUB_REPOSITORY']
link = f"https://github.com/{repository}"
commits = os.environ['GITHUB_COMMIT']
# count = len(os.environ['GITHUB_PuSH_NUMBER'])
date = time.ctime()
text = f"📌 Push effectué par {author} 🧠 \n Date: {date} \n \n Commits: {commits[:25]} ... \n sentez vous libre l'examiné {link}"
send_msg(text)


if __name__ == '__main__':
send_msg_on_push()

0 comments on commit 9f54575

Please sign in to comment.