-
Notifications
You must be signed in to change notification settings - Fork 2
/
action.yml
140 lines (128 loc) · 4.83 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: 'Spotify GitHub Action Stats'
description: 'Show your spotify stats inside your README.md'
branding:
icon: "activity"
color: "green"
inputs:
author_name:
description: "The name of the committer"
required: false
default: "GitHub Actions"
author_email:
description: "The email address of the committer"
required: false
default: "41898282+github-actions[bot]@users.noreply.github.com"
commit_message:
description: "The commit message to use for the commit"
required: false
default: "docs(readme): Update Spotify Stats"
update_mode:
description: "Decide whether to update README files, SVGs, or both"
required: true
default: "README"
# Update SVGs Inputs
# Update READMEs Inputs
readme_list:
description: "A list of comma separated paths to the READMEs files to be updated"
required: false
default: "README.md"
# Last Played Songs Args
update_last_played_songs:
description: "Whether to update the recently played songs section"
required: false
default: false
last_played_songs_template_path:
description: "The path of the template to use"
required: false
default: "last_played_songs.md"
last_played_songs_to_show:
description: "How many recently listened songs to show"
required: false
default: 5
# Top Artists Args
update_user_top_artists:
description: "Whether to update the user top artists section"
required: false
default: false
top_artists_template_path:
description: "The path of the template to use"
required: false
default: "user_top_artists.md"
top_artists_to_show:
description: "How many top artists to show"
required: false
default: 5
# Most Played Songs Args
update_user_most_played_songs:
description: "Whether to update the user most played songs section"
required: false
default: false
most_played_template_path:
description: "The path of the template to use"
required: false
default: "user_most_played.md"
most_played_songs_to_show:
description: "How many most played songs to show"
required: false
default: 5
outputs:
markdown:
description: "The section markdown as output"
value: ${{ steps.generate-readme-update.outputs.markdown }}
committed:
description: "Whether the action has created a commit ('true' or 'false')"
value: ${{ steps.add-and-commit.outputs.committed }}
commit_long_sha:
description: "The full SHA of the commit that has just been created"
value: ${{ steps.add-and-commit.outputs.commit_long_sha }}
commit_sha:
description: "The short 7-character SHA of the commit that has just been created"
value: ${{ steps.add-and-commit.outputs.commit_sha }}
pushed:
description: "Whether the action has pushed to the remote ('true' or 'false')"
value: ${{ steps.add-and-commit.outputs.pushed }}
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Python dependencies
shell: bash
run: python -m pip install -r ${{ github.action_path }}/action-requirements.txt
- name: Update README
id: "update-readme"
if: ${{ inputs.update_mode == 'README' || inputs.update_mode == 'BOTH' }}
shell: bash
run: |
UPDATE=$(python ${{ github.action_path }}/src/update_readmes.py \
--readme-list "${{ inputs.readme_list }}" \
--update-last-played-songs "${{ inputs.update_last_played_songs }}" \
--last-played-songs-template-path "${{ inputs.last_played_songs_template_path }}" \
--last-played-songs-to-show "${{ inputs.last_played_songs_to_show }}" \
--update-user-top-artists "${{ inputs.update_user_top_artists }}" \
--user-top-artists-template-path "${{ inputs.top_artists_template_path }}" \
--user-top-artists-num-of-artists-to-show "${{ inputs.top_artists_to_show }}" \
--update-user-most-played-songs "${{ inputs.update_user_most_played_songs }}" \
--user-most-played-template-path "${{ inputs.most_played_template_path }}" \
--most-played-songs-to-show "${{ inputs.most_played_songs_to_show }}" \
) || exit 1
echo "markdown=$(echo $UPDATE)" >> $GITHUB_OUTPUT
- name: Update SVGs
id: "update-svgs"
if: ${{ inputs.update_mode == 'SVG' || inputs.update_mode == 'BOTH' }}
shell: bash
run: |
UPDATE=$(python ${{ github.action_path }}/src/update_svgs.py \
) || exit 1
echo "markdown=$(echo $UPDATE)" >> $GITHUB_OUTPUT
- name: Commit Changes
id: "add-and-commit"
uses: EndBug/add-and-commit@v9
with:
message: "${{ inputs.commit_message }}"
author_name: "${{ inputs.author_name }}"
author_email: "${{ inputs.author_email }}"