GitHub Actions 工作流,每天在配置文件存储库的 文件中自动更新 每周图表中的封面。

GitHub Actions 工作流,每天在配置文件存储库的 文件中自动更新 每周图表中的封面。

Jun 21, 2022 10:02 AM
notion image to markdown

notion image

About this repo

notion image
This is a small project that I started because I wanted to have my 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 file.

Example output, automatically updated every day

notion image
notion image
notion image
notion image
notion image
notion image

👩🏽‍💻 What you'll need

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


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

 - cron: '2 0 * * *'

 runs-on: ubuntu-latest
 - uses: actions/checkout@v2
 - name: lastfm to markdown
 uses: melipass/lastfm-to-markdown@v1.3.1
 LASTFM_USER: ${{ secrets.LASTFM_USER }}
# INCLUDE_LINK: true # Optional. Defaults is false. If you want to include the link to the album page, set this to true.
# IMAGE_COUNT: 6 # Optional. Defaults to 10. Feel free to remove this line if you want.
 - name: commit changes
 continue-on-error: true
 run: |
 git config --local ""
 git config --local "GitHub Action"
 git add -A
 git commit -m "Updated's weekly chart" -a

 - name: push changes
 continue-on-error: true
 uses: ad-m/github-push-action@v0.6.0
 github_token: ${{ secrets.GITHUB_TOKEN }}\
 branch: main
The cron job is scheduled to run once a day because'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's API was down at the time, going to the Actions tab in your repository.

To do

notion image
  • Allow users to choose the image size for the album covers.
  • Feel free to open an issue or send a pull request for anything you believe would be useful.