Skip to content

Commit 0919d75

Browse files
authored
Merge branch 'main' into patch-1
2 parents 28d2e3d + 2e1ccf5 commit 0919d75

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

.github/workflows/tryhackme-badge-action-workflow

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ on:
77

88
jobs:
99
update-badge:
10-
runs-on: ubuntu-latest
11-
10+
runs-on: ubuntu-22.04
1211
steps:
1312
- name: Checkout repository
1413
uses: actions/checkout@v2
@@ -22,6 +21,5 @@ jobs:
2221
uses: DhanushNehru/[email protected]
2322
with:
2423
image_path: './assets/tryhackme-badge.png'
25-
username: 'thm username'
26-
user_id: 'github user.id'
24+
user_id: 'your_tryhackme_user_id'
2725
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ 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).
18-
- user_id: Your TryHackMe user ID (defaults to the value in a secret named THM_USER_ID).
17+
- user_id: Your TryHackMe user ID (defaults to the value in a secret named THM_USER_ID). Eg) 1995656
1918

2019
```
2120
name: Update TryHackMe Badge
@@ -27,7 +26,7 @@ on:
2726
2827
jobs:
2928
update-badge:
30-
runs-on: ubuntu-latest
29+
runs-on: ubuntu-22.04
3130
3231
steps:
3332
- name: Checkout repository
@@ -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 }}
43-
```
41+
```

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)