-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (77 loc) · 3.04 KB
/
main_release.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
78
79
name: Deploy to Prod
on:
release:
types: [published]
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
TAG: ${{ github.event.release.tag_name }}
jobs:
echo_info:
runs-on: ubuntu-latest
steps:
- name: Echo info
id: echo_message
run: echo "Github action Deploy to Prod was triggered with release tag ${{ github.event.release.tag_name }}"
check_permission:
runs-on: ubuntu-latest
steps:
- name: Get Permission
uses: octokit/[email protected]
id: get_permission
with:
route: GET /repos/${{ github.repository }}/collaborators/${{ github.actor }}/permission
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: output
run: |
export role_name=${{ fromJson(steps.get_permission.outputs.data).role_name }}
if [[ "$role_name" == "maintain" || "$role_name" == "admin" ]]; then
exit 0
else
exit 1
fi
copy_files:
runs-on: ubuntu-latest
needs: check_permission
steps:
- name: checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.ref }}
- name: Install aws cli
id: install-aws-cli
uses: unfor19/[email protected]
- name: Zip and copy files
id: copyfiles
run: |
cd ./${{ github.event.release.tag_name }}
zip files.zip *.json
aws s3 cp files.zip s3://${{ secrets.ROR_DATA_S3_BUCKET_DEV }}/${{ github.event.release.tag_name }}-v2/files.zip
aws s3 ls s3://${{ secrets.ROR_DATA_S3_BUCKET_DEV }}/${{ github.event.release.tag_name }}-v2/files.zip
- name: Notify Slack
if: always()
uses: edge/simple-slack-notify@master
env:
SLACK_WEBHOOK_URL: ${{ secrets.CURATOR_SLACK_WEBHOOK_URL }}
with:
channel: '#ror-curation-releases'
color: 'good'
text: 'Copy status to DEV S3 Bucket: ${{ steps.copyfiles.outcome }}. From directory: ${{ github.event.release.tag_name }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}'
- name: Index data
id: indexdata
run: |
cd .github/workflows
python -m pip install --upgrade pip
pip install requests==2.23.0
python index_files.py -u ${{ secrets.INDEX_DEV_API_URL_V2 }} -d ${{ github.event.release.tag_name }}-v2 -he ${{ secrets.INDEX_DEV_API_HEADERS }}
- name: Notify Slack
if: always()
uses: edge/simple-slack-notify@master
env:
SLACK_WEBHOOK_URL: ${{ secrets.CURATOR_SLACK_WEBHOOK_URL }}
with:
channel: '#ror-curation-releases'
color: 'good'
text: 'DEV index status: ${{ steps.indexdata.outcome }}. Using v2. From directory: ${{ github.event.release.tag_name }}. Please check: ${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}'