Skip to content

testing whole workflow #82

testing whole workflow

testing whole workflow #82

Workflow file for this run

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
- name: Parse output, create PR and Issue text
run: |
echo "CHANGED=$(grep -q 'DEBUG' lcsh.log && echo 'true' || echo 'false')" >> $GITHUB_ENV
{
echo "PR_BODY<<EOF"
echo "### Changed:"
echo " + lcsh.log updated with data from workflow run on $(date '+%D')"
echo "$(grep -q 'DEBUG' lcsh.log && echo '### Added:' && echo ' + New infile is: data/acc_in.csv' && echo ' + Old infile is: data/acc_in_$DATE' || echo '')"
echo EOF
} >> $GITHUB_ENV
{
echo "ISSUE_BODY<<EOF"
echo "$(grep -q 'DEBUG - Revised' lcsh.log && echo '### Changed:' && echo '$(grep "DEBUG - Revised" lcsh.log | grep -Eo "\[.+]$")' || '$(grep -q "DEBUG - Revised" lcsh.log)')"
echo "$(grep -q 'DEBUG - Deprecated' lcsh.log && echo '### Deprecated:' && echo '$(grep "DEBUG - Deprecated" lcsh.log | grep -Eo "\[.+]$")' || '$(grep -q "DEBUG - Deprecated" lcsh.log)')"
echo EOF
} >> $GITHUB_ENV
- 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")"
git push --set-upstream origin monthly_check_$(date "+%Y%m%d-%H-%M")
- name: Create PR
run: |
gh pr create \
--repo ${{ github.repository }} \
--assignee "$ASSIGNEES" \
--title "Monthly LCSH check ($(date "+%Y%m%d-%H-%M"))" \
--body "$PR_BODY")
- name: Create Issue
if: ${{ env.CHANGED == 'true' }}
run: |
gh issue create \
--title "Changes to ACC LCSH ($(date "+%Y%m%d-%H-%M"))" \
--assignee "$ASSIGNEES" \
--body "$ISSUE_BODY")