Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
music

GitHub Action

lastfm to markdown

v1.1

lastfm to markdown

music

lastfm to markdown

Adds your Last.fm Weekly Chart to your GitHub Profile or any repo with a README.md

Installation

Copy and paste the following snippet into your .yml file.

              

- name: lastfm to markdown

uses: melipass/[email protected]

Learn more about this action in melipass/lastfm-to-markdown

Choose a version

last.fm to markdown

🤖 About this repo

This is a small project that I started because I wanted to have my last.fm weekly chart on my GitHub profile. I used GitHub Actions because they can be scheduled with cron jobs and you won't need to pass any sensitive information to modify the README.md file.

🎵 My weekly last.fm chart (example output)

👩🏽‍💻 What you'll need

  • A README.md file.
  • Last.fm API key
    • Fill this form to instantly get one. Requires a last.fm account.
  • Set up a GitHub Secret called LASTFM_API_KEY with the value given by last.fm.
  • Also set up a LASTFM_USER GitHub Secret with the user you'll get the weekly charts for.
  • Add a <!-- lastfm --> tag in your README.md file, with two blank lines below it. The album covers will be placed here.

Instructions

To use this release, add a lastfm.yml workflow file to the .github/workflows folder in your repository with the following code:

name: lastfm-to-markdown

on:
  schedule:
    - cron: '2 0 * * *'
  workflow_dispatch:

jobs:
  lastfm:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: lastfm to markdown
        uses: melipass/[email protected]
        with:
          LASTFM_API_KEY: ${{ secrets.LASTFM_API_KEY }}
          LASTFM_USER: ${{ secrets.LASTFM_USER }}
      - name: commit changes
        continue-on-error: true
        run: |
          git config --local user.email "[email protected]"
          git config --local user.name "GitHub Action"
          git add -A
          git commit -m "Updated last.fm's weekly chart" -a

      - name: push changes
        continue-on-error: true
        uses: ad-m/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}\
          branch: main

The cron job is scheduled to run once a day because Last.fm's API updates weekly chart data daily at 00:00, it's useless to make more than 1 request per day because you'll get the same information back every time. You can manually run the workflow in case Last.fm's API was down at the time, going to the Actions tab in your repository.

🚧 To do

  • Allow users to choose the image size and image count for the album covers.
  • Feel free to send a PR for anything you believe would be useful.