forked from lowlighter/metrics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
571 lines (488 loc) · 19.1 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
# ====================================================================================
# Inputs and configuration
inputs:
# Personal user token
# No additional scopes are needed unless you want to include private repositories metrics
# Some plugins may also require additional scopes
token:
description: GitHub Personal Token
required: true
# Set to "${{ secrets.GITHUB_TOKEN }}"
committer_token:
description: GitHub Token used to commit metrics
default: ""
# Branch to commit
committer_branch:
description: The branch used to commit metrics
default: ""
# GitHub username
# Optional, as it defaults "token"'s owner
user:
description: GitHub username
default: ""
# Output path for generated metrics, relative to repository's root
filename:
description: Path of SVG image output
default: github-metrics.svg
# Optimize SVG image with SVGO
# It minifies and removes useless attributes
# Some templates may not support this option
optimize:
description: SVG optimization
default: yes
# Timezone used by metrics
# See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
# Some plugins will use it to calibrate dates
config_timezone:
description: Timezone used
default: ""
# Metrics output type
# Supported values are :
# - svg
# - png (does not support animations)
# - jpeg (does not support animations and transparency)
config_output:
description: Output image type
default: svg
# Enable or disable SVG CSS animations
config_animations:
description: SVG CSS animations
default: yes
# Configure padding for output image (percentage)
# It can be used to add padding to generated metrics if rendering is cropped or has too much empty space
# You can specify one value (for both width and height) and two values (one for width and one for height, seperated by a comma)
config_padding:
description: Image padding
default: 6%
# Configure metrics content order (comma-separated values)
# Specify in which order base and plugins will be displayed
# It is not mandatory to specify all partials when using this option, in this case, remaining parts will be appended
#
# For example, to display "base.repositories" before "base.activity" and "base.community" in "classic template" you can use:
# config_order: base.header, base.repositories, base.activity+community
#
# See source/templates/*/partials/_.json for a list of supported partials for each template.
config_order:
description: Configure metrics content order
default: ""
# Number of repositories to use for metrics
# A high number increase metrics accuracy, but will consume additional API requests when using plugins
repositories:
description: Number of repositories to use
default: 100
# Template to use
# See https://github.com/lowlighter/metrics/tree/master/source/templates for supported templates
template:
description: Template to use
default: classic
# Raw query parameters (JSON string)
# Some templates may require additional parameters which you can specify here
# Do not use this option to pass plugins parameters as they'll be overwritten by the other options
query:
description: Additional query parameters
default: "{}"
# Template base content
# Pass a string of comma-separated values
# To disable everything (like if you want to use a plugin as standalone), pass an empty string
# Supported values are :
# - "header" (name, commits calendar, ...)
# - "activity" (commits, issues/pull requests opened, ...)
# - "community" (following, stars, sponsors, ...)
# - "repositories" (license, stars, forks, ...)
# - "metadata" (svg generation metadata)
base:
description: Base content to include in metrics
default: "header, activity, community, repositories, metadata"
# Google PageSpeed plugin
# Enable it to compute the performance of provided website
plugin_pagespeed:
description: Enable Google PageSpeed metrics for user's website
default: no
# Website to audit with PageSpeed
# Leave empty to default to the website attached to "user"'s GitHub account
plugin_pagespeed_url:
description: Website to audit with PageSpeed
default: ""
# Display additional PageSpeed audit metrics
# The following are displayed :
# First Contentful Paint, Speed Index, Largest Contentful Paint, Time to Interactive, Total Blocking Time, Cumulative Layout Shift
# See https://web.dev/performance-scoring/ and https://googlechrome.github.io/lighthouse/scorecalc/ for more informations
plugin_pagespeed_detailed:
description: Display additional PageSpeed metrics
default: no
# Display the final screenshot of audited website taken by PageSpeed audit
plugin_pagespeed_screenshot:
description: Display a screenshot of your website
default: no
# PageSpeed API token (optional, avoid hitting requests limit)
# See https://developers.google.com/speed/docs/insights/v5/get-started for more informations
plugin_pagespeed_token:
description: Pagespeed personal token
default: ""
# Lines of code plugin
# Compute added/removed line for each of you repositories from your contributors stats
plugin_lines:
description: Enable lines of code metrics
default: no
# Traffic plugin ("token" must have "repo" permission)
# Count views on your repositories
plugin_traffic:
description: Enable repositories traffic metrics
default: no
# Coding habits plugin
# Search in your recent activity what've recently did and deduce facts/charts
plugin_habits:
description: Enable coding habits metrics
default: no
# Number of activity events to base habits on
# Capped to 1000
plugin_habits_from:
description: Number of activity events to use
default: 200
# Number of days to base habits on (older events will be discarded)
# Capped to 30
plugin_habits_days:
description: Number of days to use
default: 14
# Display tidbits about your active hours/days, indent used (spaces/tabs), etc. deduced from recent activity
plugin_habits_facts:
description: Display habits facts based on recent activity
default: yes
# Display charts of most active time of the day and languages recently used
plugin_habits_charts:
description: Display recent coding activity charts
default: no
# Languages plugins
# Compute the most used programming languages on your repositories
plugin_languages:
description: Enable most used languages metrics
default: no
# List of ignored languages, comma separated
# Ignored languages won't count towards your languages metrics
plugin_languages_ignored:
description: List of ignored languages
default: ""
# List of skipped repositories, comma separated
# Skipped repositories won't count towards your languages metrics
plugin_languages_skipped:
description: List of skipped repositories
default: ""
# Follow-up plugin
# Display the number and the ratio of opened/closed issues and opened/merged pull requests on your repositories
plugin_followup:
description: Enable owned repositories issues and pull requests metrics
default: no
# Music plugin
# Display tracks you recently listened or your favorite tracks from a playlist
plugin_music:
description: Enable music plugin
default: no
# Music provider
# Required in "recent" mode
# Optional in "playlist" mode (will be deduced from "plugin_music_playlist" url)
# Supported values are :
# - "apple" for Apple Music
# - "spotify" for Spotify
plugin_music_provider:
description: Name of the music provider you're using
default: ""
# Music personal token
# This may be required depending on the music provider and the mode you use
# - "apple" : not required
# - "spotify" : required for "recent" mode, format is "client_id, client_secret, refresh_token"
plugin_music_token:
description: Music provider personal token
default: ""
# Music plugin mode
# Supported values are :
# - "playlist" : display tracks from a playlist randomly
# - "recent" : display recently played tracks
plugin_music_mode:
description: Use "recent" to display recently played music and "playlist" to display tracks randomly from a given playlist
default: ""
# Music playlist
# The embed playlist url (source which is used for music player iframes)
# Will default "plugin_music_mode" to "playlist" when set
plugin_music_playlist:
description: Embed playlist url
default: ""
# Number of tracks to display for music plugin
plugin_music_limit:
description: Number of tracks to display
default: 4
# Posts plugin
# Display recent posts from an external source
plugin_posts:
description: Enable recent posts display
default: no
# Posts source
# This is required when "plugin_posts" is enabled
# Supported values are :
# - "dev.to" for dev.to
plugin_posts_source:
description: Posts external source
default: ""
# Posts source username
# Leave empty to default to the login "user"'s GitHub account
plugin_posts_user:
description: Posts external source username
default: ""
# Number of posts to display
plugin_posts_limit:
description: Number of posts to display
default: 4
# Isometric calendar plugin
# Display an isometric view of your commits calendar along with a few stats like current streak and average commits per day
plugin_isocalendar:
description: Display an isometric view of your commits calendar along with a few additional stats
default: no
# Duration shown by isometric calendar plugin
# Supported values are "half-year" and "full-year"
plugin_isocalendar_duration:
description: Set isometric calendar duration
default: half-year
# Gists plugin
# Display gists metrics
plugin_gists:
description: Display gists metrics
default: no
# Topics plugin
# Display starred topics
plugin_topics:
description: Display starred topics
default: no
# Topics plugin mode
# Change the way topics are displayed
# Supported values are :
# - "starred" to display starred topics as interests labels
# - "mastered" to display starred topics as mastered/known technologies icons
plugin_topics_mode:
description: Display starred topics
default: "starred"
# Sorting method of displayed topics
# Supported values are :
# - "stars" to sort them from most starred to least starred
# - "activity" to sort them from most recent activity to least recent activity
# - "starred" to sort them from your most recently starred to your least recently starred
# - "random" to sort them randomly
plugin_topics_sort:
description: Sorting method of starred topics
default: "stars"
# Number of topics to display (between 0 and 20)
# If more topics must be displayed, they will be grouped in an ellipsis
plugin_topics_limit:
description: Number of starred topics to display
default: ""
# Projects plugin
# Display active projects
plugin_projects:
description: Display active projects
default: no
# Display active repository projects
# By default, only user owned projects are displayed, with this option it is possible to display projects from repositories
# List of comma-separated projects identifier, in the following format :user/:repo/projects/:project_id
# The limit of displayed projects will automatically be updated so listed projects will fit
plugin_projects_repositories:
description: List of repository project identifiers to disaplay
default: ""
# Number of active projects to display
# Between 1 and 100
plugin_projects_limit:
description: Number of active projects to display
default: 4
# Tweets plugin
# Enable it to display recent tweets of the twitter username attached to "user"
plugin_tweets:
description: Display recent tweets
default: no
# Twitter username
# Leave empty to default to the twitter account attached to "user"'s GitHub account
plugin_tweets_user:
description: Twitter username
default: ""
# Tweets API token (required when tweets plugin is enabled)
# See https://apps.twitter.com for more informations
plugin_tweets_token:
description: Twitter bearer token
default: ""
# Number of tweets to display
# Between 1 and 10
plugin_tweets_limit:
description: Number of tweets to display
default: 2
# Display recently starred repositories
plugin_stars:
description: Display recently starred repositories
default: no
# Number of recently starred repositories to display
plugin_stars_limit:
description: Number of recently starred repositories to display
default: 4
# Display stargazers evolution over the last two weeks
# It shows total stargazers along with increase rate per day
plugin_stargazers:
description: Display stargazers evolution over the last two weeks
default: no
# Display recent activity
plugin_activity:
description: Display recent activity
default: no
# Number of activity events to display
# Capped to 100
plugin_activity_limit:
description: Number of activity events to display
default: 5
# Discard older events
# Use 0 to display activity whatever the date
plugin_activity_days:
description: Maximum activity event age
default: 14
# Events type to display
# Pass a string of comma-separated values
# Supported values are
# - "comment" for all kind of comments (commits, issue and pr)
# - "ref/create" and "ref/delete" for tag and branch creation/deletion
# - "release" for new published releases
# - "wiki" for wiki edition
# - "push" for pushed commits
# - "issue" and "pr" for issues and pull requests
# - "review" for pull requests review
# - "public" for repositories made public
# - "fork" and "star" for forked and starred repositories
# - "member" for accepted repository invitations
plugin_activity_filter:
description: Events to display
default: all
# Display followed and following users
plugin_people:
description: Display
default: no
# Limit the number of users displayed
plugin_people_limit:
description: Number of users to display per categorie
default: 28
# Configure image size of users' avatar
plugin_people_size:
description: Size of users' avatars
default: 28
# List of users categories to display (comma separated)
# Supported values are:
# - "followers"
# - "following"
plugin_people_types:
description: Categories to display
default: followers, following
# Display GitHub identicons instead of users' real avatar
# Mostly for privacy purposes
plugin_people_identicons:
description: Use identicons instead of real avatars
default: no
# ====================================================================================
# Options below are mostly used for testing
# When enabled, any plugins errors will throw
# By default, metrics are still generated with an error message
plugins_errors_fatal:
description: Die on plugins errors
default: no
# Enable debug mode
debug:
description: Enable debug logs
default: no
# Verify SVG after generation
# Test whether SVG can be correctly parsed
verify:
description: Verify SVG after generation
default: no
# Debug flags
debug_flags:
description: Debug flags
default: ""
# Enable dry-run mode
# Generate image but does not push it
dryrun:
description: Enable dry-run
default: no
# Use mocked data
# Bypass external APIs which requires a token and sent mocked data
use_mocked_data:
description: Use mocked data instead of real APIs
default: no
# Use pre-built image from GitHub registry (experimental)
# See https://github.com/users/lowlighter/packages/container/package/metrics for more information
use_prebuilt_image:
description: Use pre-built image from GitHub registry
default: ""
# ====================================================================================
# Action metadata
name: GitHub metrics as SVG image
author: lowlighter
description: An SVG generator with 20+ metrics about your GitHub account! Additional plugins are available to display even more!
branding:
icon: user-check
color: gray-dark
# The action will parse its name to check if it's the official action or if it's a forked one
# On the official action, it'll use the docker image published on GitHub registry when using a released version, allowing faster runs
# On a forked action, it'll rebuild the docker image from Dockerfile to take into account changes you made
runs:
using: composite
steps:
- run: |
# Create environment file from inputs and GitHub variables
cd $METRICS_ACTION_PATH
touch .env
for INPUT in $(echo $INPUTS | jq -r 'to_entries|map("INPUT_\(.key|ascii_upcase)=\(.value|@uri)")|.[]'); do
echo $INPUT >> .env
done
env | grep -E '^(GITHUB|ACTIONS|CI)' >> .env
echo "Environment variable: loaded"
# Source repository (picked from action name)
METRICS_SOURCE=$(echo $METRICS_ACTION | sed -E 's/metrics.*?$//g')
echo "Source: $METRICS_SOURCE"
# Version (picked from package.json)
METRICS_VERSION=$(grep -Po '(?<="version": ").*(?=")' package.json)
echo "Version: $METRICS_VERSION"
# Image tag (extracted from version or from env)
METRICS_TAG=v$(echo $METRICS_VERSION | sed -r 's/^([0-9]+[.][0-9]+).*/\1/')
if [[ $METRICS_USE_PREBUILT_IMAGE ]]; then
METRICS_TAG=$METRICS_USE_PREBUILT_IMAGE
echo "Pre-built image: yes"
fi
echo "Image tag: $METRICS_TAG"
# Image name
# Pre-built image
if [[ $METRICS_USE_PREBUILT_IMAGE ]]; then
echo "Using pre-built version $METRICS_TAG, will pull docker image from GitHub registry"
METRICS_IMAGE=ghcr.io/lowlighter/metrics:$METRICS_TAG
# Official action
elif [[ $METRICS_SOURCE == "lowlighter" ]]; then
# Is unreleased version
set +e
METRICS_IS_RELEASED=$(expr $(expr match $METRICS_VERSION .*-beta) == 0)
set -e
echo "Is released version: $METRICS_IS_RELEASED"
# Rebuild image for unreleased version
if [[ "$METRICS_IS_RELEASED" -gt "0" ]]; then
echo "Using released version $METRICS_TAG, will pull docker image from GitHub registry"
METRICS_IMAGE=ghcr.io/lowlighter/metrics:$METRICS_TAG
# Use registry for released version
else
echo "Using an unreleased version, rebuilding docker image from Dockerfile"
docker build -t metrics:unreleased .
METRICS_IMAGE=metrics:unreleased
fi
# Forked action
else
echo "Using a forked version, rebuilding docker image from Dockerfile"
docker build -t metrics:forked .
METRICS_IMAGE=metrics:forked
fi
echo "Image name: $METRICS_IMAGE"
# Run docker image with current environment
docker run --volume $GITHUB_EVENT_PATH:$GITHUB_EVENT_PATH --env-file .env $METRICS_IMAGE
rm .env
shell: bash
env:
METRICS_ACTION: ${{ github.action }}
METRICS_ACTION_PATH: ${{ github.action_path }}
METRICS_USE_PREBUILT_IMAGE: ${{ inputs.use_prebuilt_image }}
INPUTS: ${{ toJson(inputs) }}