Skip to content

Commit

Permalink
build(actions): create action
Browse files Browse the repository at this point in the history
  • Loading branch information
izayl committed Jan 3, 2021
1 parent 3b14921 commit 301bfd9
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 162 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/spotify-box.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: spotify-box
on:
schedule:
- cron: '0 0 * * *' # Runs at 00:00 UTC every day
push:
branches: master
jobs:
updateTopTracks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- name: Update
uses: ./
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GIST_ID: ${{ secrets.GIST_ID }}
SPOTIFY_CLIENT_ID: ${{ secrets.SPOTIFY_CLIENT_ID }}
SPOTIFY_CLIENT_SECRET: ${{ secrets.SPOTIFY_CLIENT_SECRET }}
SPOTIFY_REFRESH_TOKEN: ${{ secrets.SPOTIFY_REFRESH_TOKEN }}
11 changes: 11 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: spotify-box
author: izayl
description: GitHub Action for Update a gist to contain your weekly top tracks on Spotify.

runs:
using: node12
main: ./index.js

branding:
icon: music
color: green
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ async function updateTopTracks(json) {
artist = truncate(artist, 19)

const line = [
name.padEnd(34 + name.length - eaw.length(name), '·'),
artist.padStart(20 + artist.length - eaw.length(artist), '·'),
name.padEnd(34 + name.length - eaw.length(name)),
artist.padStart(20 + artist.length - eaw.length(artist)),
]
lines.push(line.join('|'))
lines.push(line.join(''))
}

try {
Expand All @@ -52,7 +52,7 @@ async function updateTopTracks(json) {
gist_id,
files: {
[filename]: {
filename: '🎵 Spotify Top Track',
filename: '🎵 My Spotify Top Track',
content: lines.join('\n'),
},
},
Expand Down
174 changes: 174 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions sample.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
GH_TOKEN=
GIST_ID=
SPOTIFY_CLIENT_ID=
SPOTIFY_CLIENT_SECRET=
SPOTIFY_REFRESH_TOKEN=
158 changes: 0 additions & 158 deletions yarn.lock

This file was deleted.

0 comments on commit 301bfd9

Please sign in to comment.