Skip to content

Commit

Permalink
correct handling git push for plotting information
Browse files Browse the repository at this point in the history
  • Loading branch information
JHogenboom committed Aug 6, 2024
1 parent d705883 commit 4b19de9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/update_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ permissions:

jobs:
execute-vantage6-task:
runs-on: [self-hosted, SURF]
runs-on: [ self-hosted, SURF ]
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand Down Expand Up @@ -77,12 +77,20 @@ jobs:
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
git config --global user.name "${{ github.actor }}"
- name: Commit and push if there are changes
# Commit of aggregate data is done separately to cater for Datawrapper's automatic updates
- name: Commit and push aggregate data
run: |
git add data/*
git status --short | grep "plotting_info.json" && git add plotting_info.json
git status --short | grep "plotting_info.json" && git add plotting_info.json
git commit -m "Add/update Vantage6 result" || exit 0 # Exit gracefully if no changes
git push
- name: Run Datawrapper script
run: python scripts/datawrapper.py "${{ secrets.DATAWRAPPER_TOKEN }}" plotting_info.json
run: python scripts/datawrapper.py "${{ secrets.DATAWRAPPER_TOKEN }}" plotting_info.json

# Commit of plotting information is done separately so that Datawrapper chart id and embedding code can be updated
- name: Commit and push plotting information data
run: |
git status --short | grep "plotting_info.json" && git add plotting_info.json
git commit -m "Update plotting information" || exit 0 # Exit gracefully if no changes
git push
2 changes: 1 addition & 1 deletion scripts/datawrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,5 @@ def retrieve_embedding_component(api_token, chart_id):
plotting_info[variable]['embedding_code'] = embedding_code

# Save updated plotting information back to JSON file
with open(os.path.join(os.path.dirname(os.getcwd()), plotting_information_path), 'w') as f:
with open(plotting_information_path, 'w') as f:
json.dump(plotting_info, f)

0 comments on commit 4b19de9

Please sign in to comment.