-
Notifications
You must be signed in to change notification settings - Fork 1
31 lines (29 loc) · 1.11 KB
/
refresh-token.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
name: refresh-token
on:
schedule:
- cron: '*/5 * * * *'
push:
branches:
- main
jobs:
get-token:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- name: Install jq
run: sudo apt install jq
- name: Get token
run: curl 'https://developers.google.com/oauthplayground/refreshAccessToken' -X POST --data-raw "{\"token_uri\":\"https://oauth2.googleapis.com/token\",\"client_id\":\"517222506229-vsmmajv00ul0bs7p89v5m89qs8eb9359.apps.googleusercontent.com\",\"client_secret\":\"$CLIENT_SECRET\",\"refresh_token\":\"$REFRESH_TOKEN\"}" | jq -r .access_token > token
env:
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }}
- name: Commit token
run: |
git config --global user.name 'Global Witness build script'
git config --global user.email 'data@globalwitness.org'
git add token
timestamp=$(date -u)
git pull
git commit -m "New Google Earth Engine access token: ${timestamp}" || exit 0
git push