Skip to content

Export playlist chart #233

Export playlist chart

Export playlist chart #233

name: "Export playlist chart"
on:
workflow_dispatch: {}
schedule:
- cron: "45 5 * * 0" # weekly (sunday) at 05:45 UTC
jobs:
playlistChart:
name: "Export Spotify Playlist statistics chart and commit on repository"
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@master
with:
fetch-depth: 1
- name: "Setup Python"
uses: actions/setup-python@master
with:
python-version: "3.8"
architecture: "x64"
- name: "Hash requirements files for cache key"
id: hash_requirements
run: |-
cat spotify_client/requirements.txt >> /tmp/requirements.hash
cat spotify_client/requirements.plotly.txt >> /tmp/requirements.hash
echo "::set-output name=hash::$(printf $(sha256sum /tmp/requirements.hash))"
- name: "Cache Python packages"
uses: actions/cache@v2
with:
key: "python_cache_chart-${{ steps.hash_requirements.outputs.hash }}"
path: |
~/.cache/pip
~/.local/lib/python3.8/site-packages
- name: "Install Python requirements"
run: pip install --user -r spotify_client/requirements.txt -r spotify_client/requirements.plotly.txt
- name: "Export stats"
run: python run_spotify_client.py export_stats
env:
PLAYLIST_STATS_FILE: playlist_stats.ndjson
PLAYLIST_FILE: playlist.tsv
SPOTIFY_CLIENT_ID: ${{ secrets.SPOTIFY_CLIENT_ID }}
SPOTIFY_CLIENT_SECRET: ${{ secrets.SPOTIFY_CLIENT_SECRET }}
SPOTIFY_REFRESH_TOKEN: ${{ secrets.SPOTIFY_REFRESH_TOKEN }}
SPOTIFY_PLAYLIST_ID: ${{ secrets.SPOTIFY_PLAYLIST_ID }}
- name: "Export chart"
run: python run_spotify_client.py export_chart
env:
PLAYLIST_STATS_FILE: playlist_stats.ndjson
PLAYLIST_CHART_FILE: playlist_chart.svg
- name: Git Commit & Push
uses: EndBug/add-and-commit@v7
with:
add: "playlist_stats.ndjson playlist_chart.svg"
message: "Export playlist stats & chart"
push: true