-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (64 loc) · 2.37 KB
/
monthly-run.yaml
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: monthly lcsh check
on:
schedule:
- cron: '40/5 20 9 * *'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
ASSIGNEES: charlottekostelic
jobs:
monthly-run:
name: Run monthly LCSH check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: Create branch
run: git checkout -b monthly_check_$(date "+%Y%m%d-%H-%M-%S")
- name: Run script
run: |
python monthly_lcsh_check.py
- name: Commit and push changed files
run: |
git config user.name "Charlotte Kostelic"
git config user.email "[email protected]"
git add lcsh.log
git add data/*
git commit -a -m "LCSH Check $(date "+%Y%m%d-%H-%M-%S")"
git push --set-upstream origin monthly_check_$(date "+%Y%m%d-%H-%M-%S")
- name: Parse changes
run: |
echo "CHANGED=$(grep 'DEBUG - Revised' lcsh.log | grep -Eo '\[.+]$')" >> $GITHUB_ENV
echo "DEPRECATED=$(grep 'DEBUG - Deprecated' lcsh.log | grep -Eo '\[.+]$')" >> $GITHUB_ENV
- name: Create PR
run: |
echo "### Changed" >> $PR_BODY
if [[ ! -z "$CHANGED" ]];
echo "### Added" >> $PR_BODY
echo "+ New infile is: data/acc_in.csv" >> $PR_BODY
echo "+ Old infile is: data/acc_in_$DATE.csv" >> $PR_BODY
gh pr create \
--repo ${{ github.repository }} \
--assignee "$ASSIGNEES" \
--title "Monthly LCSH check ($(date "+%Y%m%d-%H-%M-%S"))" \
--body "$PR_BODY")
- name: Create Issue
if: ${{ contains(fromJSON(*), env.CHANGED) == true || contains(fromJSON(*), env.DEPRECATED) == true}}
run: |
if [[ ! -z "$CHANGED" ]];
echo "### Changed" >> $ISSUE_BODY
echo $CHANGED >> $ISSUE_BODY
if [[ ! -z "$DEPRECATED" ]];
echo "### Deprecated" >> $ISSUE_BODY
echo $DEPRECATED >> $ISSUE_BODY
gh issue create \
--title "Changes to ACC LCSH" \
--assignee "$ASSIGNEES" \
--body "$ISSUE_BODY")