-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
40 lines (38 loc) · 1.64 KB
/
cron_watcher.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# A GitHub Action to verify that certain Open Library cron jobs have completed successfully.
# Data dumps happen on the 1st day of the month so check on them on the 2nd day of the month.
# Partner dumps happen on the 17th day of the month so check on them on the 18th day of the month.
# Always check again two days later in case they needed to be re-run.
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
name: cron_watcher
on:
schedule: # At 3:45am on the 2nd, 4th, 18th, and 20th day of the month.
- cron: '45 3 2,4,18,20 * *' # https://cron.help
workflow_dispatch: # This job can also be run on-demand.
permissions:
contents: read
jobs:
cron_watcher:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: pip install internetarchive slack-sdk
- run: scripts/cron_watcher.py
continue-on-error: true
id: cron_watcher_step
- if: steps.cron_watcher_step.outcome != 'success'
shell: python
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
SLACK_CHANNEL_ABC_TEAM_PLUS: ${{ secrets.SLACK_CHANNEL_ABC_TEAM_PLUS }}
run: |
import os, sys, slack_sdk
token = os.getenv("SLACK_TOKEN")
channel = os.getenv("SLACK_CHANNEL_ABC_TEAM_PLUS")
if token and channel:
slack_sdk.WebClient(token=token).chat_postMessage(channel=channel,
text="<https://github.com/internetarchive/openlibrary/actions/workflows/cron_watcher.yml|`cron_watcher`> has failed.",
)
sys.exit(1)