monthly lcsh check #40
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: '45/5 13 10 * *' | ||
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") | ||
- 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")" | ||
git push --set-upstream origin monthly_check_$(date "+%Y%m%d-%H-%M") | ||
- name: Parse changes | ||
id: changes | ||
env: | ||
Check failure on line 44 in .github/workflows/monthly-run.yaml GitHub Actions / monthly lcsh checkInvalid workflow file
|
||
run: | | ||
echo "CHANGED=$(grep 'DEBUG - Revised' lcsh.log | grep -Eo '\[.+]$')" >> $GITHUB_OUTPUT | ||
echo "DEPRECATED=$(grep 'DEBUG - Deprecated' lcsh.log | grep -Eo '\[.+]$')" >> $GITHUB_OUTPUT | ||
- name: Create PR | ||
run: | | ||
echo "### Changed" >> $PR_BODY | ||
echo "+ lcsh.log updated with data from workflow" >> $PR_BODY | ||
if [[ toJSON(steps.changes.outputs.CHANGED) != {} || toJSON(steps.changes.outputs.DEPRECATED) != {} ]]; | ||
echo "### Added" >> $PR_BODY | ||
echo "+ New infile is: data/acc_in.csv" >> $PR_BODY | ||
echo "+ Old infile is: data/acc_in_$(date "+%Y%m%d").csv" >> $PR_BODY | ||
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: ${{ toJSON(steps.changes.outputs.CHANGED) != {} || toJSON(steps.changes.outputs.DEPRECATED) != {} }} | ||
run: | | ||
if [[ ! -z ${{ steps.changes.outputs.CHANGED }} ]]; | ||
echo "### Changed" >> $ISSUE_BODY | ||
echo ${{ steps.changes.outputs.CHANGED }} >> $ISSUE_BODY | ||
if [[ ! -z ${{ steps.changes.outputs.DEPRECATED }} ]]; | ||
echo "### Deprecated" >> $ISSUE_BODY | ||
echo ${{ steps.changes.outputs.DEPRECATED }} >> $ISSUE_BODY | ||
gh issue create \ | ||
--title "Changes to ACC LCSH ($(date "+%Y%m%d-%H-%M"))" \ | ||
--assignee "$ASSIGNEES" \ | ||
--body "$ISSUE_BODY") |