forked from openedx/.github
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add email alerts functionality in repo health job
- Loading branch information
1 parent
303d605
commit dbcec79
Showing
1 changed file
with
46 additions
and
6 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 |
---|---|---|
|
@@ -3,7 +3,7 @@ name: Repo Health Checks | |
on: | ||
workflow_call: | ||
secrets: | ||
REPO_HEALTH_BOT_TOKEN: | ||
REPO_HEALTH_BOT_TOKEN: | ||
description: "Github token with read access to all repos and write access to the target repo" | ||
required: true | ||
REPO_HEALTH_BOT_EMAIL: | ||
|
@@ -15,6 +15,17 @@ on: | |
READTHEDOCS_API_KEY: | ||
description: "API Key for READ THE DOCS Access" | ||
required: true | ||
EMAIL_ADDRESS_FOR_ALERTS: | ||
description: "Email Address for the failure alerts" | ||
type: string | ||
default: "" | ||
required: false | ||
EDX_SMTP_USERNAME: | ||
description: "SMTP Username for sending emails" | ||
required: false | ||
EDX_SMTP_USERNAME: | ||
description: "SMTP Username for sending emails" | ||
required: false | ||
|
||
inputs: | ||
DASHBOARD_NAME: | ||
|
@@ -53,6 +64,22 @@ on: | |
description: "Space seperated list of repos to be ignored i.e. 'repo1 repo2 . . .' " | ||
type: string | ||
default: "clamps-ghsa-c4rq-qwgr-pj5h" | ||
CALLER_REPOSITORY: | ||
description: "Repository that called this workflow" | ||
type: string | ||
default: "" | ||
CALLER_WORKFLOW: | ||
description: "Workflow that called this workflow" | ||
type: string | ||
default: "" | ||
CALLER_RUN_ID: | ||
description: "Run ID of the caller repository" | ||
type: string | ||
default: "" | ||
ENABLE_EMAIL_ALERTS_ON_SUCCESS: | ||
description: "By default, email alerts are sent on failure. Set this to true to enable email alerts on success as well." | ||
type: boolean | ||
default: false | ||
|
||
jobs: | ||
repo_health_check: | ||
|
@@ -70,14 +97,14 @@ jobs: | |
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Clone edx-repo-health repo | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: openedx/edx-repo-health | ||
path: edx-repo-health | ||
ref: ${{ inputs.EDX_REPO_HEALTH_BRANCH }} | ||
|
||
- name: Install pip & pip-tools | ||
run: | | ||
python3 -m pip install -r edx-repo-health/requirements/pip.txt | ||
|
@@ -89,14 +116,14 @@ jobs: | |
repository: openedx/testeng-ci | ||
path: testeng-ci | ||
ref: "master" | ||
|
||
- name: Clone repo-tools repo | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: openedx/repo-tools | ||
path: repo_tools | ||
ref: master | ||
|
||
- name: Clone repo-health-data repo | ||
uses: actions/checkout@v4 | ||
with: | ||
|
@@ -137,10 +164,23 @@ jobs: | |
if: ${{ inputs.DASHBOARD_NAME == 'repo_health' }} | ||
run: | | ||
bash edx-repo-health/scripts/repo-health-artifact.sh | ||
- name: Upload sqlite db as artifact | ||
if: ${{ inputs.DASHBOARD_NAME == 'repo_health' }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: sqlite db artifact | ||
path: dashboards/dashboard.sqlite3 | ||
|
||
- name: Send email | ||
uses: dawidd6/action-send-mail@v3 | ||
if: ${{ secrets.EMAIL_ADDRESS_FOR_ALERTS != '' }} | ||
with: | ||
server_address: email-smtp.us-east-1.amazonaws.com | ||
server_port: 465 | ||
username: ${{secrets.EDX_SMTP_USERNAME}} | ||
password: ${{secrets.EDX_SMTP_PASSWORD}} | ||
subject: ${{ github.event.result == 'success' && inputs.ENABLE_EMAIL_ALERTS_ON_SUCCESS && '${{ inputs.CALLER_WORKFLOW }} workflow succeeded' || '${{ inputs.CALLER_WORKFLOW }} workflow failed' }} in ${{ inputs.CALLER_REPOSITORY }} | ||
to: ${{ secrets.EMAIL_ADDRESS_FOR_ALERTS }} | ||
from: github-actions <[email protected]> | ||
body: "N/A" |