Skip to content

Commit aa08cec

Browse files
authored
Updated thm badge which comes with live updates
1 parent 812809d commit aa08cec

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ This is a GitHub Action that fetches your latest TryHackMe badge, downloads it,
1414
- Configure the action with the following inputs:
1515
- GITHUB_TOKEN: Your GitHub Personal Access Token (required, set as a secret).
1616
- image_path: The path to store the downloaded badge image (defaults to ./assets/tryhackme-badge.png).
17-
- username: Your TryHackMe username (defaults to the value in a secret named THM_USERNAME).
1817
- user_id: Your TryHackMe user ID (defaults to the value in a secret named THM_USER_ID).
1918

2019
```
@@ -37,7 +36,6 @@ jobs:
3736
uses: DhanushNehru/[email protected]
3837
with:
3938
image_path: './assets/tryhackme-badge.png'
40-
username: 'your_tryhackme_username'
4139
user_id: 'your_tryhackme_user_id'
4240
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4341
```

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const fs = require("fs");
55

66
const GITHUB_TOKEN = core.getInput("GITHUB_TOKEN");
77
const FILE_PATH = core.getInput("image_path") || "./assets/tryhackme-badge.png";
8-
const THM_USERNAME = core.getInput("username") || "dhanushnehru";
8+
// const THM_USERNAME = core.getInput("username") || "dhanushnehru";
99
const THM_USER_ID = core.getInput("user_id") || "1995656";
1010

1111
/*
@@ -15,6 +15,7 @@ const THM_USER_ID = core.getInput("user_id") || "1995656";
1515
* @param options {Object} extra options
1616
* @return {Promise<Object>}
1717
*/
18+
1819
const executeCommand = (cmd, args = [], options = {}) =>
1920
new Promise((resolve, reject) => {
2021
let outputData = "";
@@ -61,10 +62,10 @@ const refreshBadge = async (userId) => {
6162
}
6263
};
6364

64-
const downloadAndCommitBadge = async (githubToken, filePath, username) => {
65+
const downloadAndCommitBadge = async (githubToken, filePath, userID) => {
6566
await refreshBadge(THM_USER_ID);
6667
try {
67-
const url = `https://tryhackme-badges.s3.amazonaws.com/${username}.png`;
68+
const url = `https://tryhackme.com/api/v2/badges/public-profile?userPublicId=${userID}`
6869
const path = filePath;
6970
const committerUsername = core.getInput("committer_username");
7071
const commitMessage = core.getInput("commit_message") || "Updated THM profile badge using action workflow by Dhanush Nehru";
@@ -101,4 +102,4 @@ const downloadAndCommitBadge = async (githubToken, filePath, username) => {
101102
}
102103
};
103104

104-
downloadAndCommitBadge(GITHUB_TOKEN, FILE_PATH, THM_USERNAME);
105+
downloadAndCommitBadge(GITHUB_TOKEN, FILE_PATH, THM_USER_ID);

0 commit comments

Comments
 (0)