Skip to content

Commit

Permalink
External PR notifier GH action
Browse files Browse the repository at this point in the history
  • Loading branch information
cbbayburt committed Aug 16, 2023
1 parent 4125a00 commit 9c81847
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/external_pr_notifier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: External PR notifier

on:
schedule:
# Every monday at 08:00 UTC
- cron: '0 8 * * 1'

jobs:
query_prs:
name: Report external PRs
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
sparse-checkout: .github/workflows/external_pr_notifier
- id: list_prs
name: Get a list of external PRs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# List non-draft PRs that have 'community' label, excluding bots
gh pr list -R uyuni-project/uyuni -l community -s open --json number,title,author,url,isDraft \
-q '{"prs": map(select(.isDraft == false and .author.is_bot == false))}' > external_prs.json
COUNT=`jq '.prs | length' external_prs.json`
echo "::notice::$COUNT PRs with label 'community' found."
echo "count=$COUNT" >> "$GITHUB_OUTPUT"
- name: Compile email template
if: ${{ steps.list_prs.outputs.count > 0 }}
uses: cuchi/jinja2-action@v1.2.0
with:
template: .github/workflows/external_pr_notifier/template.md.j2
output_file: template.md
data_file: external_prs.json
- name: Send weekly summary email
if: ${{ steps.list_prs.outputs.count > 0 }}
uses: cbbayburt/action-send-mail@v1
with:
server_address: ${{ secrets.EMAIL_SERVER }}
server_port: 587
username: ${{ secrets.EMAIL_USERNAME }}
password: ${{ secrets.EMAIL_PASSWORD }}
subject: "Uyuni Project - Community contributions"
to: ${{ secrets.EMAIL_TO }}
from: ${{ secrets.EMAIL_FROM }}
html_body: file://template.md
ignore_cert: true
convert_markdown: true
33 changes: 33 additions & 0 deletions .github/workflows/external_pr_notifier/template.md.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{#
jinja template for Uyuni external contributions weekly notification emails.
The PR data is available via the 'prs' key in the followng format:
prs: [
{
author: {
id,
is_bot,
login,
name
},
isDraft,
number,
title,
url
}
]
#}
# Uyuni Project - Community contributions

There are {{ prs|length }} open pull requests from external contributors in [uyuni-project](https://github.com/uyuni-project/uyuni) this week.

{% for pr in prs %}
- [#{{ pr.number }}]({{ pr.url }}) - {{ pr.title }} ([{{ pr.author.login }}](https://github.com/{{ pr.author.login }}))
{%- endfor %}

*Draft pull requests are excluded from the list.*

You can also check out the full list [here](https://github.com/uyuni-project/uyuni/pulls?q=is%3Apr+is%3Aopen+draft%3Afalse+label%3Acommunity).

---
*This e-mail is auto-generated by the [External PR notifier](https://github.com/cbbayburt/uyuni/actions/workflows/external_pr_notifier.yml) GitHub action.*

0 comments on commit 9c81847

Please sign in to comment.