chore: cache charts

This commit is contained in:
Cory Dransfeldt 2023-11-15 18:41:49 +00:00
parent 8320c4cf24
commit a2d50cee46
4 changed files with 33 additions and 31 deletions

View file

@ -13,11 +13,15 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Fetch current artist charts
run: |-
data=$(curl 'https://ws.audioscrobbler.com/2.0/?method=user.getweeklyartistchart&user=coryd_&api_key=${{ secrets.LASTFM_API_KEY }}&format=json') \
charts=$(src/_data/json/weekly-artist-charts.json | jq --argjson jq_data "${data}" '.charts += [$jq_data]') \
echo $charts > src/_data/json/weekly-artist-charts.json
- name: Fetch charts
run: |
echo "CHART_DATA=$(curl 'https://ws.audioscrobbler.com/2.0/?method=user.getweeklyartistchart&user=coryd_&api_key=${{ secrets.LASTFM_API_KEY }}&format=json')" >> "$GITHUB_ENV"
- name: Update charts
run: |
echo "CHARTS=$(cat src/_data/json/weekly-artist-charts.json | jq -c --argjson jq_data "$CHART_DATA" '.charts += [$jq_data]')" >> "$GITHUB_ENV"
- name: Write charts
run: |
echo $CHARTS > src/_data/json/weekly-artist-charts.json
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v5
with: