|
| 1 | +name: Update last modified date |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + date-value: |
| 6 | + type: string |
| 7 | + description: Date value to populate last_modified field with (YYYY-MM-DD) |
| 8 | + directory-name: |
| 9 | + type: string |
| 10 | + description: Name of parent directory containing new/updated records. Needed only if different from branch name. |
| 11 | +jobs: |
| 12 | + update-last-mod: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: checkout |
| 16 | + uses: actions/checkout@v2 |
| 17 | + with: |
| 18 | + ref: ${{ github.event.ref }} |
| 19 | + - name: Set up Python environment |
| 20 | + uses: actions/setup-python@v2 |
| 21 | + with: |
| 22 | + python-version: "3.8" |
| 23 | + - name: Get directory name |
| 24 | + if: "${{ github.event.inputs.directory-name != '' }}" |
| 25 | + run: echo "WORKING_DIR=${{ github.event.inputs.directory-name }}" >> $GITHUB_ENV |
| 26 | + - name: Get branch name |
| 27 | + if: "${{ github.event.inputs.directory-name == '' }}" |
| 28 | + run: echo "WORKING_DIR=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV |
| 29 | + - name: Update last modified |
| 30 | + id: updatelastmod |
| 31 | + working-directory: ${{ env.WORKING_DIR }} |
| 32 | + run: | |
| 33 | + python -m pip install --upgrade pip |
| 34 | + curl https://raw.githubusercontent.com/ror-community/curation_ops/v2-crosswalk/utilities/update_last_mod/update_last_mod.py -o update_last_mod.py |
| 35 | + python update_last_mod.py -d ${{ github.event.inputs.date-value }} |
| 36 | + - name: commit error file |
| 37 | + if: ${{ steps.updatelastmod.outcome != 'success'}} |
| 38 | + working-directory: ${{ env.WORKING_DIR }} |
| 39 | + run: | |
| 40 | + echo "ERRORS found for some records:" |
| 41 | + cat update_last_mod_errors.log |
| 42 | + - name: commit changed files |
| 43 | + if: ${{ steps.updatelastmod.outcome == 'success'}} |
| 44 | + uses: stefanzweifel/git-auto-commit-action@v4 |
| 45 | + with: |
| 46 | + file_pattern: ${{ env.WORKING_DIR }}/**.json |
| 47 | + commit_message: Apply last mod changes to files |
| 48 | + - name: Set env variable for notification |
| 49 | + if: always() |
| 50 | + run: | |
| 51 | + if [[ ${{ steps.updatelastmod.outcome }} == 'success' ]]; then |
| 52 | + echo "update_last_mod_status=SUCCESS" >> $GITHUB_ENV |
| 53 | + else |
| 54 | + echo "update_last_mod_status=FAILED" >> $GITHUB_ENV |
| 55 | + fi |
| 56 | + - name: Notify Slack |
| 57 | + if: always() |
| 58 | + uses: edge/simple-slack-notify@master |
| 59 | + env: |
| 60 | + SLACK_WEBHOOK_URL: ${{ secrets.CURATOR_SLACK_WEBHOOK_URL }} |
| 61 | + VALIDATION_STATUS: ${{ env.update_last_mod_status }} |
| 62 | + with: |
| 63 | + channel: '#ror-curation-releases' |
| 64 | + color: 'good' |
| 65 | + 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' |
0 commit comments