Skip to content

dxnter/lastfm-readme

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

90 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
lastfm-readme branding hero

๐ŸŽต Last.fm README GitHub Action

Dynamically update your GitHub README.md with Last.fm metrics.

MIT License GitHub Release

lastfm-readme preview output

๐Ÿš€ Quick Start

Tip

New to GitHub Actions? Check out the GitHub Actions documentation to get started.

๐Ÿ”ง Setup

๐ŸŽต Last.fm API Key

  1. Create a Last.fm API account: Visit Last.fm API
  2. Get your API key: You'll receive an API key immediately after account creation
  3. Save your API key: You'll need this for the next step

Warning

Keep your API key secure and never commit it directly to your repository.

๐Ÿ”’ Configure Repository Secrets

Step 1: Navigate to your repository's secrets:

Your Repository โ†’ Settings โ†’ Secrets and variables โ†’ Actions โ†’ New repository secret

Step 2: Add the required secrets:

Secret NameDescriptionRequired
LASTFM_API_KEY Your Last.fm API key from the previous step โœ… Yes
GH_TOKEN GitHub Personal Access Token with repo scope
Only needed for cross-repository updates
โš ๏ธ Conditional

โš™๏ธ Configure Workflow Permissions

Important

This step is crucial for the action to update your README file.

Path: Settings โ†’ Actions โ†’ General โ†’ Workflow permissions

Setting: Select "Read and write permissions"

Workflow permissions configuration

๐Ÿ“ Add Section Markers to Your README

Add HTML comments to your README.md where you want your Last.fm data to appear:

<!-- Add this where you want your music stats -->
<!--START_LASTFM_ARTISTS-->
<!--END_LASTFM_ARTISTS-->

<!--START_LASTFM_RECENT-->
<!--END_LASTFM_RECENT-->

๐Ÿ’ผ Create Your Workflow

Create .github/workflows/lastfm.yml in your repository:

name: ๐ŸŽต Update Last.fm Stats

on:
  # Run automatically every 6 hours
  schedule:
    - cron: '0 */6 * * *'
  # Allow manual runs
  workflow_dispatch:

jobs:
  update-lastfm:
    name: ๐ŸŽค Update Music Stats
    runs-on: ubuntu-latest

    steps:
      - name: ๐ŸŽต Update Last.fm README
        uses: dxnter/lastfm-readme@v1
        with:
          LASTFM_API_KEY: ${{ secrets.LASTFM_API_KEY }}
          LASTFM_USER: your-lastfm-username

          # Optional: Customize the commit message
          COMMIT_MESSAGE: '๐ŸŽต Update music stats'

          # Optional: For cross-repository updates
          # GH_TOKEN: ${{ secrets.GH_TOKEN }}
          # REPOSITORY: username/repository

          # Optional: Target a different file
          # TARGET_FILE: profile/README.md
โฐ Scheduling Examples
Frequency Cron Expression
Every hour 0 * * * *
Every 6 hours 0 */6 * * *
Daily at midnight 0 0 * * *
Weekly 0 0 * * 0

For different scheduling needs, refer to the crontab.guru website.

โš™๏ธ Configuration

๐Ÿ“ฅ Input Parameters

Parameter Required Default Description
LASTFM_API_KEY โœ… Yes โ€” Your Last.fm API key
LASTFM_USER โœ… Yes โ€” Last.fm username to fetch data for
GH_TOKEN ๐Ÿ”ถ Optional ${{ github.token }} GitHub token for cross-repo updates
REPOSITORY ๐Ÿ”ถ Optional Current repository Target repository (owner/repo)
TARGET_FILE ๐Ÿ”ถ Optional README.md Path to the file to update
COMMIT_MESSAGE ๐Ÿ”ถ Optional chore: update Last.fm sections Custom commit message
SHOW_TITLE ๐Ÿ”ถ Optional true Show section titles with Last.fm logo
LOCALE ๐Ÿ”ถ Optional en-US BCP 47 locale for number formatting
DATE_FORMAT ๐Ÿ”ถ Optional MM/dd/yyyy date-fns format for dates

๐Ÿ“Š Available Sections

Note

Each section is defined by HTML comment markers with optional JSON configuration for customization.

๐ŸŽฏ Basic Usage

<!-- Default configuration -->
<!--START_LASTFM_ARTISTS-->
<!--END_LASTFM_ARTISTS-->

๐Ÿ› ๏ธ Advanced Configuration

<!-- Custom configuration with JSON -->
<!--START_LASTFM_ARTISTS:{"period": "overall", "rows": 3}-->
<!--END_LASTFM_ARTISTS-->
๐Ÿ’ก Configuration Tips
  • JSON must be valid: Use double quotes for keys and string values
  • No spaces: Keep the configuration compact
  • Multiple sections: You can use the same section type multiple times with different configs

Example of multiple artist sections:

<!-- This week's top artists -->
<!--START_LASTFM_ARTISTS:{"period": "7day", "rows": 5}-->
<!--END_LASTFM_ARTISTS-->

<!-- All-time favorites -->
<!--START_LASTFM_ARTISTS:{"period": "overall", "rows": 3}-->
<!--END_LASTFM_ARTISTS-->

๐ŸŽค Top Artists

Display the top listened to albums over a given period of time.

๐Ÿ–ผ๏ธ Preview

top-artists.png

๐Ÿ’ป Usage Examples

<!-- Default: Top 8 artists from the past week -->
<!--START_LASTFM_ARTISTS-->
<!--END_LASTFM_ARTISTS-->

<!-- Custom: Top 5 artists from the past 6 months -->
<!--START_LASTFM_ARTISTS:{"period": "6month", "rows": 5}-->
<!--END_LASTFM_ARTISTS-->

<!-- All-time favorites -->
<!--START_LASTFM_ARTISTS:{"period": "overall", "rows": 10}-->
<!--END_LASTFM_ARTISTS-->

โš™๏ธ Configuration Options

OptionTypeDefaultOptionsDescription
period string 7day 7day, 1month, 3month, 6month, 12month, overall Time period for data aggregation
rows number 8 1-50 Number of artists to display

๐Ÿ’ฟ Top Albums

Display the top listened to albums over a given period of time.

๐Ÿ–ผ๏ธ Preview

top-albums.png

๐Ÿ’ป Usage Examples

<!-- This month's top albums -->
<!--START_LASTFM_ALBUMS:{"period": "1month", "rows": 5}-->
<!--END_LASTFM_ALBUMS-->

<!-- All-time classic albums -->
<!--START_LASTFM_ALBUMS:{"period": "overall", "rows": 3}-->
<!--END_LASTFM_ALBUMS-->

โš™๏ธ Configuration Options

OptionTypeDefaultOptionsDescription
period string 7day 7day, 1month, 3month, 6month, 12month, overall Time period for data aggregation
rows number 8 1-50 Number of albums to display

๐ŸŽต Top Tracks

Display the top listened to tracks over a given period of time.

๐Ÿ–ผ๏ธ Preview

top-tracks.png

๐Ÿ’ป Usage Examples

<!-- This month's most played songs -->
<!--START_LASTFM_TRACKS:{"period": "1month", "rows": 5}-->
<!--END_LASTFM_TRACKS-->

<!-- Your all-time favorites -->
<!--START_LASTFM_TRACKS:{"period": "overall", "rows": 10}-->
<!--END_LASTFM_TRACKS-->

โš™๏ธ Configuration Options

OptionTypeDefaultOptionsDescription
period string 7day 7day, 1month, 3month, 6month, 12month, overall Time period for data aggregation
rows number 8 1-50 Number of tracks to display

๐Ÿ”Š Recent Tracks

Display most recently played music with real-time "now playing" status.

๐Ÿ–ผ๏ธ Preview

Default

recent-tracks.png

Track currently playing

recent-tracks-now-playing.png

๐Ÿ’ป Usage Examples

<!-- Default: Last 8 tracks -->
<!--START_LASTFM_RECENT-->
<!--END_LASTFM_RECENT-->

<!-- Custom: Last 5 tracks -->
<!--START_LASTFM_RECENT:{"rows": 5}-->
<!--END_LASTFM_RECENT-->

โš™๏ธ Configuration Options

OptionTypeDefaultOptionsDescription
rows number 8 1-50 Number of recent tracks to display

โ„น๏ธ User Statistics

Showcase your Last.fm profile statistics and listening milestones.

๐Ÿ–ผ๏ธ Preview

Default

recent-tracks.png

Custom Configuration

user-info-custom.png

๐Ÿ’ป Usage Examples

<!-- Default: Show all available statistics -->
<!--START_LASTFM_USER_INFO-->
<!--END_LASTFM_USER_INFO-->

<!-- Custom: Only show play count and artist count -->
<!--START_LASTFM_USER_INFO:{"display": ["playcount", "artistCount"]}-->
<!--END_LASTFM_USER_INFO-->

<!-- Minimal: Just registration date -->
<!--START_LASTFM_USER_INFO:{"display": ["registered"]}-->
<!--END_LASTFM_USER_INFO-->

โš™๏ธ Configuration Options

OptionTypeDefaultAvailable OptionsDescription
display array All fields registered, playcount, artistCount, albumCount, trackCount List of statistics to display
๐Ÿ“Š Available Statistics Fields
Field Description Example Output
registered Account registration date Registered: 12/25/2015
playcount Total scrobbled tracks Playcount: 50,247
artistCount Unique artists listened to Artists: 2,847
albumCount Unique albums in library Albums: 8,429
trackCount Unique tracks in library Tracks: 45,821

๐ŸŒŸ Acknowledgements

This project was inspired by and builds upon the excellent work of:

About

๐ŸŽถ Dynamically update your GitHub README with Last.fm metrics

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •