Create a Last.fm API account if you don't have one to receive an API Key.
Navigate to your repositories Settings β Secrets and variables β Actions β New repository secret
to add the following secrets:
Name | Value |
---|---|
LASTFM_API_KEY |
A valid Last.fm API Key |
GH_TOKEN * |
A GitHub Access Token with the repo scope granted |
*
GH_TOKEN
is only required when the intention is to modify aREADME.md
file in a repository outside where the workflow is running.
Navigate to your repositories Settings β Actions β General β Workflow permissions
and select the Read and write permissions option.
The README.md
file must contain HTML comments that identify where the charts should be inserted. Commonly, a profile repository is used to host the README.md
file.
Note
See the Charts section for configuration details.
name: Last.fm Charts
on:
workflow_dispatch: # Allow manual triggering of workflow
schedule:
# Run every 6 hours
- cron: '0 */6 * * *'
jobs:
lastfm-metrics:
name: Update Last.fm Charts
runs-on: ubuntu-latest
steps:
- uses: dxnter/lastfm-readme@v1
with:
LASTFM_API_KEY: ${{ secrets.LASTFM_API_KEY }}
LASTFM_USER: dxnter
# The following inputs below are only required when the intention is to modify a README.md file in a repository outside where the workflow is running
#GH_TOKEN: ${{ secrets.GH_TOKEN }}
#REPOSITORY: <gh_username/gh_username>
Setting | Default | Accepted Values | Description |
---|---|---|---|
LASTFM_API_KEY |
N/A | Last.fm API Key | A valid Last.fm API Key |
LASTFM_USER |
N/A | Last.fm username | The Last.fm user to fetch metrics from |
GH_TOKEN |
${{ github.token }} |
GitHub access token | An access token with the repo scope granted. |
REPOSITORY |
<gh_username>/<gh_username> |
<gh_username>/<repo_name> |
Repository that should have the README.md file updated. |
COMMIT_MESSAGE |
chore: update Last.fm sections |
Any string | Commit message used when sections are updated |
SHOW_TITLE |
true |
true / false |
Toggle the title shown above sections |
LOCALE |
en-US |
BCP 47 tag | Locale used for formatting numbers |
DATE_FORMAT |
MM/dd/yyyy |
date-fns date format | Date format used in the User Info section |
All charts are identified by HTML comments that contain a valid chart name and an optional JSON configuration object followed by a closing HTML comment.
Chart with the default configuration (period: "7day", rows: 8)
<!--START_LASTFM_...-->
<!--END_LASTFM_...-->
Chart with a custom configuration
<!--START_LASTFM_...:{"period": "overall", "rows": 3}-->
<!--END_LASTFM_...-->
Display the top listened to artists over a given period of time.
<!--START_LASTFM_ARTISTS:{"period": "6month", "rows": 3}-->
<!--END_LASTFM_ARTISTS-->
Option | Default | Options | Description |
---|---|---|---|
period |
7day |
7day , 1month , 3month , 6month , 12month , overall |
The period of time to display data from |
rows |
8 |
1 β€ integer β€ 50 | The number of artists to display |
Display the top listened to albums over a given period of time.
<!--START_LASTFM_ALBUMS:{"period": "1month", "rows": 3}-->
<!--END_LASTFM_ALBUMS-->
Option | Default | Options | Description |
---|---|---|---|
period |
7day |
7day , 1month , 3month , 6month , 12month , overall |
The period of time to display data from |
rows |
8 |
1 β€ integer β€ 50 | The number of albums to display |
Display the top listened to tracks over a given period of time.
<!--START_LASTFM_TRACKS:{"period": "1month", "rows": 3}-->
<!--END_LASTFM_TRACKS-->
Option | Default | Options | Description |
---|---|---|---|
period |
7day |
7day , 1month , 3month , 6month , 12month , overall |
The period of time to display data from |
rows |
8 |
1 β€ integer β€ 50 | The number of tracks to display |
Display recently listened to tracks.
<!--START_LASTFM_RECENT:{"rows": 3}-->
<!--END_LASTFM_RECENT-->
Default
Track currently playing
Option | Default | Options | Description |
---|---|---|---|
rows |
8 |
1 β€ integer β€ 50 | The number of recent tracks to display |
Display information about a Last.fm user. An optional configuration object can be passed to specify which properties to display.
<!--START_LASTFM_USER_INFO-->
<!--END_LASTFM_USER_INFO-->
<!--START_LASTFM_USER_INFO:{"display": ["playcount", "artistCount"]}-->
<!--END_LASTFM_USER_INFO-->
Option | Default | Options | Description |
---|---|---|---|
display |
["registered", "playcount", "artistCount", "albumCount", "trackCount"] |
registered, playcount, artistCount, albumCount, trackCount |
A list of properties to be included in the section |