Update last modified date #3
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: Update last modified date | |
on: | |
workflow_dispatch: | |
inputs: | |
date-value: | |
type: string | |
description: Date value to populate last_modified field with (YYYY-MM-DD) | |
directory-name: | |
type: string | |
description: Name of parent directory containing new/updated records. Needed only if different from branch name. | |
jobs: | |
update-last-mod: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.ref }} | |
- name: Set up Python environment | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.8" | |
- name: Get directory name | |
if: "${{ github.event.inputs.directory-name != '' }}" | |
run: echo "WORKING_DIR=${{ github.event.inputs.directory-name }}" >> $GITHUB_ENV | |
- name: Get branch name | |
if: "${{ github.event.inputs.directory-name == '' }}" | |
run: echo "WORKING_DIR=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | |
- name: Update last modified | |
id: updatelastmod | |
working-directory: ${{ env.WORKING_DIR }} | |
run: | | |
python -m pip install --upgrade pip | |
curl https://raw.githubusercontent.com/ror-community/curation_ops/v2-crosswalk/utilities/update_last_mod/update_last_mod.py -o update_last_mod.py | |
python update_last_mod.py -d ${{ github.event.inputs.date-value }} | |
- name: commit error file | |
if: ${{ steps.updatelastmod.outcome != 'success'}} | |
working-directory: ${{ env.WORKING_DIR }} | |
run: | | |
echo "ERRORS found for some records:" | |
cat update_last_mod_errors.log | |
- name: commit changed files | |
if: ${{ steps.updatelastmod.outcome == 'success'}} | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
file_pattern: ${{ env.WORKING_DIR }}/**.json | |
commit_message: Apply last mod changes to files | |
- name: Set env variable for notification | |
if: always() | |
run: | | |
if [[ ${{ steps.updatelastmod.outcome }} == 'success' ]]; then | |
echo "update_last_mod_status=SUCCESS" >> $GITHUB_ENV | |
else | |
echo "update_last_mod_status=FAILED" >> $GITHUB_ENV | |
fi | |
- name: Notify Slack | |
if: always() | |
uses: edge/simple-slack-notify@master | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.CURATOR_SLACK_WEBHOOK_URL }} | |
VALIDATION_STATUS: ${{ env.update_last_mod_status }} | |
with: | |
channel: '#ror-curation-releases' | |
color: 'good' | |
text: 'DEV last mod update status: ${env.VALIDATION_STATUS}. Branch: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/tree/${env.GITHUB_REF_NAME}. Directory: ${{ env.WORKING_DIR }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID} for more details' |