-
Notifications
You must be signed in to change notification settings - Fork 0
38 lines (37 loc) · 1.43 KB
/
update_ebi_index.yaml
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
name: Update EBI index
on:
release:
types: [published]
workflow_dispatch:
jobs:
update_ebi_index:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Run python script to get new dates
id: index_updater
run: |
RELEASE=$(gh release list -L 1 --json tagName --jq '.[0].tagName')
RELEASE_DATE=$(gh release list -L 1 --json publishedAt --jq '.[0].publishedAt[:10]')
echo "status=$(python EBI/update_index_json.py --release $RELEASE --release-date $RELEASE_DATE)" >> $GITHUB_OUTPUT
- name: Push the changes on successful update
if: ${{ steps.index_updater.outputs.status == 'updated' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE_TO_COMMIT: EBI/pathogens_portal_index.json
DESTINATION_BRANCH: develop
run: |
export TODAY=$(date +%Y-%m-%d)
export MESSAGE="Update EBI index - $TODAY"
export SHA=$( git rev-parse $DESTINATION_BRANCH:$FILE_TO_COMMIT )
export CONTENT=$( base64 -i $FILE_TO_COMMIT )
gh api --method PUT /repos/:owner/:repo/contents/$FILE_TO_COMMIT \
--field message="$MESSAGE" \
--field content="$CONTENT" \
--field encoding="base64" \
--field branch="$DESTINATION_BRANCH" \
--field sha="$SHA"