-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
169 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import logging | ||
import os | ||
import re | ||
import smtplib | ||
import ssl | ||
|
||
import github | ||
|
||
logging.basicConfig(format='[%(asctime)s] %(message)s') | ||
logging.root.setLevel(logging.INFO) | ||
|
||
mailinglist_message = "The [mpg123-devel mailing list](https://sourceforge.net/p/mpg123/mailman/mpg123-devel/) has been notified of the existence of this pr." | ||
mailinglist_label = "mailing-list-notified" | ||
|
||
g = github.Github(os.environ["GITHUB_TOKEN"]) | ||
user_me = g.get_user() | ||
repo = g.get_repo(os.environ["GITHUB_REPOSITORY"]) | ||
|
||
for pr in repo.get_pulls(state="open"): | ||
logging.info("Checking PR #%d", pr.number) | ||
already_handled = False | ||
for label in pr.get_labels(): | ||
if label.name == mailinglist_label: | ||
already_handled = True | ||
if already_handled: | ||
continue | ||
|
||
logging.info("PR #%d was NOT handled already", pr.number) | ||
|
||
mail_body = f"""\ | ||
A pull request by {pr.user.login} was opened at {pr.created_at}. | ||
Please visit {pr.html_url} to give feedback and review the code. | ||
--- | ||
{pr.body} | ||
--- | ||
patch details: | ||
- url: {pr.html_url} | ||
- patch: {pr.html_url}.patch | ||
url details: | ||
- user name: {pr.user.login} | ||
- user url: {pr.user.html_url} | ||
""" | ||
logging.info("mail body: %s", mail_body) | ||
|
||
mail_title = "Opened GH-#{}: {} [{}]".format(pr.number, pr.title, pr.user.login) | ||
|
||
logging.info("mail title: %s", mail_title) | ||
logging.info("mail body: %s", mail_body) | ||
|
||
mail_message = f"""\ | ||
MIME-Version: 1.0 | ||
Content-type: text/plain; charset=utf-8 | ||
Subject: {mail_title} | ||
{mail_body} | ||
""" | ||
|
||
sender_email = "{} <{}>".format("{} (via github PR)".format(pr.user.login), os.environ["MAIL_SENDER"]) | ||
receiver_email = os.environ["MAIL_RECEIVER"].split(";") | ||
|
||
logging.info("mail from: %s", re.sub("[a-z0-9]", "x", sender_email, flags=re.I)) | ||
logging.info("receiver to: %s", receiver_email) | ||
|
||
port = 465 | ||
server = os.environ["MAIL_SERVER"] | ||
login = os.environ["MAIL_LOGIN"] | ||
password = os.environ["MAIL_PASSWORD"] | ||
|
||
context = ssl.create_default_context() | ||
|
||
with smtplib.SMTP_SSL(server, port, context=context) as server: | ||
server.login(login, password) | ||
server.sendmail(sender_email, receiver_email, mail_message) | ||
|
||
logging.info("Creating comment at PR#%d", pr.number) | ||
pr.add_to_labels(mailinglist_label) | ||
comment = pr.create_issue_comment(mailinglist_message) | ||
logging.info("Visit comment at %s", comment.html_url) | ||
|
||
logging.info("mail sent") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
name: Ubuntu | ||
|
||
on: push | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-22.04, ubuntu-20.04] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: install updates | ||
run: sudo apt-get update && sudo apt-get dist-upgrade | ||
- name: install build system | ||
run: sudo apt-get install -y autoconf autoconf-archive automake pkg-config libtool libtool-bin libltdl-dev doxygen gcc yasm | ||
- name: install dependencies | ||
run: sudo apt-get install -y libasound2-dev libaudio-dev libjack-jackd2-dev libopenal-dev libpulse-dev libsdl1.2-dev libsdl2-dev libsndio-dev portaudio19-dev | ||
- name: setup parallel make | ||
run: echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV | ||
- name: autoreconf -iv | ||
run: autoreconf -iv | ||
- name: ./configure | ||
run: ./configure | ||
- name: make distcheck | ||
run: make distcheck | ||
name: Ubuntu | ||
|
||
on: push | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-22.04, ubuntu-20.04] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: install updates | ||
run: sudo apt-get update | ||
- name: install build system | ||
run: sudo apt-get install -y autoconf autoconf-archive automake pkg-config libtool libtool-bin libltdl-dev doxygen gcc yasm | ||
- name: install dependencies | ||
run: sudo apt-get install -y libasound2-dev libaudio-dev libjack-jackd2-dev libopenal-dev libpulse-dev libsdl1.2-dev libsdl2-dev libsndio-dev portaudio19-dev | ||
- name: setup parallel make | ||
run: echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV | ||
- name: autoreconf -iv | ||
run: autoreconf -iv | ||
- name: ./configure | ||
run: ./configure | ||
- name: make distcheck | ||
run: make distcheck |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
on: | ||
schedule: | ||
- cron: "0 * * * *" # Run every hour | ||
|
||
jobs: | ||
git_svn_sync: | ||
if: ${{ github.repository == 'madebr/mpg123' }} | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- name: "Checkout git mpg123 clone" | ||
uses: "actions/checkout@v3" | ||
with: | ||
fetch-depth: 0 | ||
token: ${{ secrets.PUSH_GITHUB_TOKEN }} | ||
- name: "Configure git client" | ||
run: | | ||
git config --global user.name "mpg123 GitHub bot" | ||
git config --global user.email "[email protected]" | ||
- name: "Download (new) revisions from mpg123 git-svn" | ||
run: | | ||
git remote add mpg123 https://mpg123.org/trunk/.git/ | ||
git fetch mpg123 | ||
- name: "Merge mpg123's master" | ||
run: | | ||
git checkout master-with-github-ci | ||
git merge mpg123/master -X ours | ||
- name: "Force push (new) master" | ||
run: | | ||
git push origin master-with-github-ci -f | ||
git push origin mpg123/master:master -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
on: | ||
schedule: | ||
- cron: "0 * * * *" # Run every hour | ||
|
||
jobs: | ||
send_mail: | ||
if: ${{ github.repository == 'madebr/mpg123' }} | ||
runs-on: "ubuntu-latest" | ||
steps: | ||
- uses: "actions/checkout@v3" | ||
- name: "Setup python" | ||
uses: "actions/setup-python@v2" | ||
with: | ||
python-version: "3.x" | ||
- name: "Install Python requirements" | ||
run: | | ||
python -m pip install --user pygithub | ||
- name: "Send mail" | ||
run: | | ||
python .github/scripts/mail-for-all-new-open-prs.py | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
MAIL_RECEIVER: ${{ secrets.MAIL_RECEIVER }} | ||
MAIL_SENDER: ${{ secrets.MAIL_SENDER }} | ||
MAIL_SERVER: ${{ secrets.MAIL_SERVER }} | ||
MAIL_LOGIN: ${{ secrets.MAIL_LOGIN }} | ||
MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }} |