Display your currently playing Spotify track in your GitHub profile README automatically using GitHub Actions and the Spotify API.
- Shows your currently playing Spotify track in your README.
- Automatically updates every 5 minutes.
- Handles “Not playing anything” if nothing is currently playing.
- Secure — Spotify credentials are stored as GitHub Secrets.
Your repository should look like this:
your-repo/
├── README.md
├── nowplaying.py # Python script that fetches current track
└── .github/
└── workflows/
└── spotify.yml
nowplaying.py: Fetches your currently playing song from Spotify and writes it tospotify.txt..github/workflows/spotify.yml: Defines the GitHub Actions workflow that runs the script every 5 minutes and updates your README.README.md: Contains a placeholder that will be replaced by your current song.
- Go to Spotify Developer Dashboard.
- Click Create an App.
- Copy Client ID and Client Secret.
- Add a Redirect URI:
http://127.0.0.1:8080/callback. - Generate a Refresh Token using the authorization code flow.
- You can use the Python script or Django flow from this repo to obtain it.
Go to your repository → Settings → Actions → Secrets and variables → Actions and add:
SPOTIFY_CLIENT_ID→ your Spotify Client IDSPOTIFY_CLIENT_SECRET→ your Spotify Client SecretSPOTIFY_REFRESH_TOKEN→ your Spotify refresh token
Add this placeholder in your README.md where you want your current song to appear:
<!-- SPOTIFY -->Loading...<!-- END_SPOTIFY -->
- <!-- SPOTIFY --> → start marker
- Loading... → default text
- <!-- END_SPOTIFY --> → end markerExample:
Loading...Upload nowplaying.py to the root of your repository.
Upload .github/workflows/spotify.yml to the workflow folder:
.github/
└── workflows/
└── spotify.yml
Before pushing to GitHub:
export SPOTIFY_CLIENT_ID="your_client_id"
export SPOTIFY_CLIENT_SECRET="your_client_secret"
export SPOTIFY_REFRESH_TOKEN="your_refresh_token"
python nowplaying.py
cat spotify.txt- This should show your currently playing track.
-
Commit and push all files (nowplaying.py, .yml, README.md).
-
Go to Actions tab → Update Spotify Now Playing → Run workflow.
-
After it runs, your README placeholder will be replaced with your current song.
After workflow runs, your README will show:
🎶 Blinding Lights — The Weeknd
or if nothing is playing:
🎧 Not playing anything
-
Make sure your GitHub Actions secrets are correct — otherwise the workflow will fail.
-
Workflow runs every 5 minutes automatically.
-
No sensitive information is exposed in your README — only your currently playing track.