Skip to content

Commit 91b0604

Browse files
authored
Faster execution speed & Byond Client Download (#19)
* A Faster Way * right * ah * AH * delete * faster * yup * test changes * more changes * more * update * update * remove test * comments * clarification * action input * update * update
1 parent cd7d194 commit 91b0604

7 files changed

Lines changed: 205 additions & 136 deletions

File tree

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
*.ts text eol=lf
22
*.js text eol=lf
3-
*.json text eol = lf
3+
*.json text eol=lf
44
*.yml text eol=lf

README.MD

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
# Round ID Linker
22

33
Replaces round id's in issue body with links to statbus.
4-
Accepted round id format :
4+
Accepted round id formats :
55
```
66
[Round ID]: 1245
7+
Round ID: 1245
8+
```
9+
10+
Also replaces Byond client version with their respective download links to both windows & linux
11+
Accepted client id format :
12+
```
13+
[Client Version]: 516.1681
14+
Client Version: 516.1681
715
```
816

917
## Usage

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ description: 'Links Round IDs found in issue body'
33
inputs:
44
repo-token:
55
description: 'The GITHUB_TOKEN secret'
6+
required: true
7+
format-version:
8+
description: 'byond client version number will be formatted as downloadable links'
9+
required: false
10+
default: true
611
runs:
712
using: 'node24'
813
main: 'dist/index.js'

dist/index.js

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28087,6 +28087,27 @@ function getInput(name, options) {
2808728087
}
2808828088
return val.trim();
2808928089
}
28090+
/**
28091+
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
28092+
* Support boolean input list: `true | True | TRUE | false | False | FALSE` .
28093+
* The return value is also in boolean type.
28094+
* ref: https://yaml.org/spec/1.2/spec.html#id2804923
28095+
*
28096+
* @param name name of the input to get
28097+
* @param options optional. See InputOptions.
28098+
* @returns boolean
28099+
*/
28100+
function getBooleanInput(name, options) {
28101+
const trueValue = ['true', 'True', 'TRUE'];
28102+
const falseValue = ['false', 'False', 'FALSE'];
28103+
const val = getInput(name, options);
28104+
if (trueValue.includes(val))
28105+
return true;
28106+
if (falseValue.includes(val))
28107+
return false;
28108+
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
28109+
`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
28110+
}
2809028111
//-----------------------------------------------------------------------
2809128112
// Results
2809228113
//-----------------------------------------------------------------------
@@ -33058,39 +33079,54 @@ function getOctokit(token, options, ...additionalPlugins) {
3305833079

3305933080
async function run() {
3306033081
try {
33061-
// Get issue number of the payload
33082+
//get issue number of the payload
3306233083
const issue_number = context.payload.issue?.number;
33063-
if (!issue_number) {
33084+
if (issue_number == undefined) {
3306433085
setFailed('Issue number retrieval failed');
3306533086
return;
3306633087
}
33067-
//github client to make requests
33068-
const octokit = getOctokit(getInput('repo-token', { required: true }));
3306933088
//get issue body
33070-
const response = await octokit.rest.issues.get({
33071-
owner: context.repo.owner,
33072-
repo: context.repo.repo,
33073-
issue_number: issue_number
33074-
});
33075-
const issue_body = response.data.body;
33089+
let issue_body = context.payload.issue?.body;
3307633090
if (!issue_body) {
33077-
setFailed('Issue body retrieval failed');
3307833091
return;
3307933092
}
33093+
//check for regex changes
33094+
let changes = false;
3308033095
//modify issue body with round link id
3308133096
const re = /(\[?Round ID\]?:\s*)(\d+)/g;
3308233097
if (issue_body.match(re)) {
33083-
const new_body = issue_body.replace(re, '$1[$2](https://statbus.space/round/$2)');
33084-
await octokit.rest.issues.update({
33085-
owner: context.repo.owner,
33086-
repo: context.repo.repo,
33087-
issue_number: issue_number,
33088-
body: new_body,
33089-
headers: {
33090-
'X-GitHub-Api-Version': '2026-03-10'
33091-
}
33092-
});
33098+
issue_body = issue_body.replace(re, '$1[$2](https://statbus.space/round/$2)');
33099+
changes = true;
33100+
}
33101+
//modify issue body with byond client download link
33102+
if (getBooleanInput('format-version')) {
33103+
const ce = /(\[?Client Version\]?:\s*)((\d+)\.(\d+))/g;
33104+
if (issue_body.match(ce)) {
33105+
issue_body = issue_body.replace(ce, '$1' + //text Client Version
33106+
'$2=>' + //full client version
33107+
'[$3](https://www.byond.com/download/build/$3)/' + //major version download page
33108+
'[Windows](https://www.byond.com/download/build/$3/$2_byond_setup.zip)/' + //windows zip file with installer
33109+
'[Linux](https://www.byond.com/download/build/$3/$2_byond_linux.zip)' //linux zip folder
33110+
);
33111+
changes = true;
33112+
}
3309333113
}
33114+
//no changes
33115+
if (!changes) {
33116+
return;
33117+
}
33118+
//github client to make requests
33119+
const octokit = getOctokit(getInput('repo-token', { required: true }));
33120+
//make request to update issue body
33121+
await octokit.rest.issues.update({
33122+
owner: context.repo.owner,
33123+
repo: context.repo.repo,
33124+
issue_number: issue_number,
33125+
body: issue_body,
33126+
headers: {
33127+
'X-GitHub-Api-Version': '2026-03-10'
33128+
}
33129+
});
3309433130
}
3309533131
catch (e) {
3309633132
setFailed(`Action failed ${e}.`);

0 commit comments

Comments
 (0)