Skip to content

Create Images and Make Release #5

Create Images and Make Release

Create Images and Make Release #5

Workflow file for this run

name: Create Images and Upload to Imgur
on:
workflow_dispatch:
schedule:
- cron: '0 12 * * *'
jobs:
upload-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Generate
run: |
python sea-surface-temps.py --mode map --dataset sst --days-ago 2 --out sst-map.png
python sea-surface-temps.py --mode map --dataset anom --days-ago 2 --out sst-anom-map.png
python sea-surface-temps.py --mode all --dataset sst --out sst-all.png
python sea-surface-temps.py --mode all --dataset anom --out sst-all-anom.png
- name: Refresh Imgur Access Token
id: refresh_token
run: |
RESPONSE=$(curl --request POST \
--url 'https://api.imgur.com/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data client_id=${{ secrets.IMGUR_CLIENT_ID }} \
--data client_secret=${{ secrets.IMGUR_CLIENT_SECRET }} \
--data refresh_token=${{ secrets.IMGUR_REFRESH_TOKEN }} \
--data grant_type=refresh_token)
echo "Response: $RESPONSE"
ACCESS_TOKEN=$(echo $RESPONSE | jq -r '.access_token')
echo "::set-output name=access_token::$ACCESS_TOKEN"
- name: Upload images to Imgur
env:
IMGUR_CLIENT_ID: ${{ secrets.IMGUR_CLIENT_ID }}
run: |
curl --request POST \
--url https://api.imgur.com/3/image \
--header 'Authorization: Bearer ${{ steps.refresh_token.outputs.access_token }}' \
--form name='sst-map.png' \
--form title='SST Map' \
--form image=@"./sst-map.png" | jq .data.link |& tee sst-map.url
curl --request POST \
--url https://api.imgur.com/3/image \
--header 'Authorization: Bearer ${{ steps.refresh_token.outputs.access_token }}' \
--form name='sst-anom-map.png' \
--form title='SST Anomaly Map' \
--form image=@"./sst-anom-map.png" jq .data.link |& tee sst-anom-map.url
curl --request POST \
--url https://api.imgur.com/3/image \
--header 'Authorization: Bearer ${{ steps.refresh_token.outputs.access_token }}' \
--form name='sst-all.png' \
--form title='SST Temps' \
--form image=@"./sst-all.png" jq .data.link |& tee sst-all.url
curl --request POST \
--url https://api.imgur.com/3/image \
--header 'Authorization: Bearer ${{ steps.refresh_token.outputs.access_token }}' \
--form name='sst-all-anom.png' \
--form title='SST Anomalies' \
--form image=@"./sst-all-anom.png" jq .data.link |& tee sst-all-anom.url
# List all upload URLs
for f in *.url; do echo $f; cat $f; done