-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (58 loc) · 2.33 KB
/
monthly-check.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
name: monthly lcsh check
on:
push:
branches:
- github-actions
# on:
# schedule:
# - cron: '* 9 15 * *'
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: Get date var
run: echo "DATE=$(date "+%Y%m%d-%H-%M-%S")" >> $GITHUB_ENV
- name: Create branch, run script
run: |
git checkout -b monthly_check_$DATE
python monthly_lcsh_check.py
echo "CHANGED=$(grep -q 'DEBUG' lcsh.log && echo 'true' || echo 'false')" >> $GITHUB_ENV
echo "REVISED=$(grep -q 'DEBUG - Revised' lcsh.log && echo 'true' || echo 'false')" >> $GITHUB_ENV
echo "DEPRECATED=$(grep -q 'DEBUG - Deprecated' lcsh.log && echo 'true' || echo 'false')" >> $GITHUB_ENV
- name: Create PR text (no changes)
run: |
{
echo "PR_BODY<<EOF"
echo "### Changed:"
echo " + lcsh.log updated with data from workflow run on $(date '+%D')"
echo "${{ [-z env.REVISED] == 'false' && '### Added:' && ' + New infile is: data/acc_in.csv' && ' + Old infile is: data/acc_in_$DATE' || '' }}"
echo EOF
} >> $GITHUB_ENV
- name: Create PR and Issue text (changes)
if: ${{ env.CHANGED == 'true' }}
run: |
{
echo "ISSUE_BODY<<EOF"
echo "${{ env.REVISED == 'true' && '### Changed:' && '$(grep "DEBUG - Revised" lcsh.log | grep -Eo "\[.+]$")' || '$(grep -q "DEBUG - Revised" lcsh.log)' }}"
echo "${{ env.DEPRECATED == 'deprecated' && '### Deprecated:' && '$(grep "DEBUG - Deprecated" lcsh.log | grep -Eo "\[.+]$")' || '$(grep -q "DEBUG - Deprecated" lcsh.log)'}}"
echo EOF
} >> $GITHUB_ENV
- name: Check PR and Issue text
run: |
echo "CHANGED: ${{ env.CHANGED }}"
echo "PR_BODY: ${{ env.PR_BODY }}"
echo "ISSUE_BODY: ${{ env.ISSUE_BODY }}"