-
Notifications
You must be signed in to change notification settings - Fork 1
77 lines (76 loc) · 3.18 KB
/
update_addresses.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Update addresses
on:
workflow_dispatch:
inputs:
schema-version:
required: true
description: Schema version
type: choice
options:
- v1
- v2
directory-name:
type: string
description: Name of parent directory containing new/updated records. Needed only if different from branch name.
jobs:
update-addresses:
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 addresses
id: updateaddresses
working-directory: ${{ env.WORKING_DIR }}
run: |
python -m pip install --upgrade pip
pip install requests==2.23.0
pip install git+https://github.com/ror-community/update_address.git
curl https://raw.githubusercontent.com/ror-community/curation_ops/v2-crosswalk/update_address_only/update_addresses.py -o update_addresses.py
if [[ ${{ github.event.inputs.schema-version }} == 'v1' ]]; then
python update_addresses.py -v 1
fi
if [[ ${{ github.event.inputs.schema-version }} == 'v2' ]]; then
python update_addresses.py -v 2
fi
- name: commit error file
if: ${{ steps.updateaddresses.outcome != 'success'}}
working-directory: ${{ env.WORKING_DIR }}
run: |
echo "ERRORS found for some records:"
cat address_update_errors.log
- name: commit changed files
if: ${{ steps.updateaddresses.outcome == 'success'}}
uses: stefanzweifel/git-auto-commit-action@v4
with:
file_pattern: ${{ env.WORKING_DIR }}/**.json
commit_message: Apply address changes to files
- name: Set env variable for notification
if: always()
run: |
if [[ ${{ steps.updateaddresses.outcome }} == 'success' ]]; then
echo "update_address_status=SUCCESS" >> $GITHUB_ENV
else
echo "update_address_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_address_status }}
with:
channel: '#ror-curation-releases'
color: 'good'
text: 'DEV address update status: ${env.VALIDATION_STATUS}. Using version ${{ github.event.inputs.schema-version }}. 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'