monthly lcsh check #31
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
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}} | ||
Check failure on line 62 in .github/workflows/monthly-run.yaml GitHub Actions / monthly lcsh checkInvalid workflow file
|
||
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") |