-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
94 lines (86 loc) · 3.02 KB
/
Copy pathaction.yml
File metadata and controls
94 lines (86 loc) · 3.02 KB
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
name: 'TryHackMe Badge'
description: 'Self-updating SVG badge for your TryHackMe stats. Five rotating themes, no headless browser. Runs from a residential machine (local cron / self-hosted runner) — TryHackMe now blocks datacenter/cloud IPs.'
author: 'KeizerSec'
branding:
icon: 'shield'
color: 'green'
inputs:
username:
description: 'Your TryHackMe username'
required: true
output_path:
description: 'Where the badge SVG will be written, relative to the repo root'
required: false
default: 'assets/thm_badge.svg'
theme:
description: 'Theme name. Either "rotate" (deterministic per UTC day), "random" (per-run), or one of: midnight, matrix, synthwave, inferno, frost.'
required: false
default: 'rotate'
accent_color:
description: 'Optional hex color (e.g. "#00FF9D") that overrides the theme accent and border.'
required: false
default: ''
auto_commit:
description: 'When true, commits and pushes the updated badge if it changed.'
required: false
default: 'true'
commit_message:
description: 'Commit message used when auto_commit is true.'
required: false
default: 'chore: refresh TryHackMe badge'
committer_name:
description: 'Git committer name used when auto_commit is true.'
required: false
default: 'github-actions[bot]'
committer_email:
description: 'Git committer email used when auto_commit is true.'
required: false
default: '41898282+github-actions[bot]@users.noreply.github.com'
outputs:
theme_used:
description: 'Name of the theme actually rendered.'
value: ${{ steps.generate.outputs.theme_used }}
rank:
description: 'Current world rank reported by the TryHackMe public API.'
value: ${{ steps.generate.outputs.rank }}
runs:
using: 'composite'
steps:
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install browser-TLS fetch dependency
shell: bash
run: python3 -m pip install --quiet --disable-pip-version-check curl_cffi
- name: Generate badge SVG
id: generate
shell: bash
env:
THM_USERNAME: ${{ inputs.username }}
OUTPUT_PATH: ${{ inputs.output_path }}
THEME: ${{ inputs.theme }}
ACCENT_COLOR: ${{ inputs.accent_color }}
run: node "${{ github.action_path }}/src/generate.js"
- name: Commit and push if changed
if: inputs.auto_commit == 'true'
shell: bash
env:
COMMIT_MSG: ${{ inputs.commit_message }}
COMMITTER_NAME: ${{ inputs.committer_name }}
COMMITTER_EMAIL: ${{ inputs.committer_email }}
OUTPUT_PATH: ${{ inputs.output_path }}
run: |
git config user.name "$COMMITTER_NAME"
git config user.email "$COMMITTER_EMAIL"
git add "$OUTPUT_PATH"
if git diff --staged --quiet; then
echo "No badge changes to commit."
exit 0
fi
git commit -m "$COMMIT_MSG"
git push