Skip to content

Commit 007af30

Browse files
committed
add ReleaseEvent support (#95)
1 parent b2349bc commit 007af30

File tree

5 files changed

+1192
-159
lines changed

5 files changed

+1192
-159
lines changed

.github/workflows/node.js.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@v2
13-
- name: Use Node.js 16.x
14-
uses: actions/setup-node@v1
12+
- uses: actions/checkout@v3
13+
- name: Use Node 16
14+
uses: actions/setup-node@v3
1515
with:
1616
node-version: 16
1717
- run: npm ci

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ name: Update README
1919

2020
on:
2121
schedule:
22-
- cron: '*/30 * * * *'
22+
- cron: "*/30 * * * *"
2323
workflow_dispatch:
2424

2525
jobs:
@@ -30,7 +30,7 @@ jobs:
3030
contents: write
3131

3232
steps:
33-
- uses: actions/checkout@v2
33+
- uses: actions/checkout@v3
3434
- uses: jamesgeorge007/github-activity-readme@master
3535
env:
3636
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -41,6 +41,7 @@ The above job runs every half an hour, you can change it as you wish based on th
4141
Please note that only those public events that belong to the following list show up:-
4242
4343
- `IssueEvent`
44+
- `ReleaseEvent`
4445
- `IssueCommentEvent`
4546
- `PullRequestEvent`
4647

@@ -50,18 +51,17 @@ You can find an example [here](https://github.com/jamesgeorge007/jamesgeorge007/
5051

5152
Use the following `input params` to customize it for your use case:-
5253

53-
| Input Param | Default Value | Description |
54-
|--------|--------|--------|
55-
| `COMMIT_MSG` | :zap: Update README with the recent activity | Commit message used while committing to the repo |
56-
| `MAX_LINES` | 5 | The maximum number of lines populated in your readme file |
57-
54+
| Input Param | Default Value | Description |
55+
| ------------ | -------------------------------------------- | --------------------------------------------------------- |
56+
| `COMMIT_MSG` | :zap: Update README with the recent activity | Commit message used while committing to the repo |
57+
| `MAX_LINES` | 5 | The maximum number of lines populated in your readme file |
5858

5959
```yml
6060
name: Update README
6161
6262
on:
6363
schedule:
64-
- cron: '*/30 * * * *'
64+
- cron: "*/30 * * * *"
6565
workflow_dispatch:
6666
6767
jobs:
@@ -72,12 +72,12 @@ jobs:
7272
contents: write
7373
7474
steps:
75-
- uses: actions/checkout@v2
75+
- uses: actions/checkout@v3
7676
- uses: jamesgeorge007/github-activity-readme@master
7777
env:
7878
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7979
with:
80-
COMMIT_MSG: 'Specify a custom commit message'
80+
COMMIT_MSG: "Specify a custom commit message"
8181
MAX_LINES: 10
8282
```
8383

dist/index.js

Lines changed: 104 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,32 @@ function parseJson (txt, reviver, context) {
13361336
}
13371337

13381338

1339+
/***/ }),
1340+
1341+
/***/ 82:
1342+
/***/ (function(__unusedmodule, exports) {
1343+
1344+
"use strict";
1345+
1346+
// We use any as a valid input type
1347+
/* eslint-disable @typescript-eslint/no-explicit-any */
1348+
Object.defineProperty(exports, "__esModule", { value: true });
1349+
/**
1350+
* Sanitizes an input into a string so it can be passed into issueCommand safely
1351+
* @param input input to sanitize into a string
1352+
*/
1353+
function toCommandValue(input) {
1354+
if (input === null || input === undefined) {
1355+
return '';
1356+
}
1357+
else if (typeof input === 'string' || input instanceof String) {
1358+
return input;
1359+
}
1360+
return JSON.stringify(input);
1361+
}
1362+
exports.toCommandValue = toCommandValue;
1363+
//# sourceMappingURL=utils.js.map
1364+
13391365
/***/ }),
13401366

13411367
/***/ 87:
@@ -1468,6 +1494,42 @@ function legacy (fs) {
14681494
}
14691495

14701496

1497+
/***/ }),
1498+
1499+
/***/ 102:
1500+
/***/ (function(__unusedmodule, exports, __webpack_require__) {
1501+
1502+
"use strict";
1503+
1504+
// For internal use, subject to change.
1505+
var __importStar = (this && this.__importStar) || function (mod) {
1506+
if (mod && mod.__esModule) return mod;
1507+
var result = {};
1508+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
1509+
result["default"] = mod;
1510+
return result;
1511+
};
1512+
Object.defineProperty(exports, "__esModule", { value: true });
1513+
// We use any as a valid input type
1514+
/* eslint-disable @typescript-eslint/no-explicit-any */
1515+
const fs = __importStar(__webpack_require__(747));
1516+
const os = __importStar(__webpack_require__(87));
1517+
const utils_1 = __webpack_require__(82);
1518+
function issueCommand(command, message) {
1519+
const filePath = process.env[`GITHUB_${command}`];
1520+
if (!filePath) {
1521+
throw new Error(`Unable to find environment variable for file command ${command}`);
1522+
}
1523+
if (!fs.existsSync(filePath)) {
1524+
throw new Error(`Missing file at path: ${filePath}`);
1525+
}
1526+
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
1527+
encoding: 'utf8'
1528+
});
1529+
}
1530+
exports.issueCommand = issueCommand;
1531+
//# sourceMappingURL=file-command.js.map
1532+
14711533
/***/ }),
14721534

14731535
/***/ 104:
@@ -1573,6 +1635,13 @@ const serializers = {
15731635
: `${emoji} ${capitalize(item.payload.action)}`;
15741636
return `${line} PR ${toUrlFormat(item)} in ${toUrlFormat(item.repo.name)}`;
15751637
},
1638+
ReleaseEvent: (item) => {
1639+
return `🚀 ${capitalize(item.payload.action)} release ${toUrlFormat(
1640+
item.payload.release.name
1641+
? item.payload.release.name
1642+
: item.payload.release.tag_name
1643+
)} in ${toUrlFormat(item.repo.name)}`;
1644+
},
15761645
};
15771646

15781647
Toolkit.run(
@@ -1615,7 +1684,9 @@ Toolkit.run(
16151684
);
16161685

16171686
if (!content.length) {
1618-
tools.exit.failure("No PullRequest/Issue/IssueComment events found");
1687+
tools.exit.failure(
1688+
"No PullRequest/Issue/IssueComment/Release events found"
1689+
);
16191690
}
16201691

16211692
if (content.length < 5) {
@@ -5345,6 +5416,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
53455416
};
53465417
Object.defineProperty(exports, "__esModule", { value: true });
53475418
const os = __importStar(__webpack_require__(87));
5419+
const utils_1 = __webpack_require__(82);
53485420
/**
53495421
* Commands
53505422
*
@@ -5398,28 +5470,14 @@ class Command {
53985470
return cmdStr;
53995471
}
54005472
}
5401-
/**
5402-
* Sanitizes an input into a string so it can be passed into issueCommand safely
5403-
* @param input input to sanitize into a string
5404-
*/
5405-
function toCommandValue(input) {
5406-
if (input === null || input === undefined) {
5407-
return '';
5408-
}
5409-
else if (typeof input === 'string' || input instanceof String) {
5410-
return input;
5411-
}
5412-
return JSON.stringify(input);
5413-
}
5414-
exports.toCommandValue = toCommandValue;
54155473
function escapeData(s) {
5416-
return toCommandValue(s)
5474+
return utils_1.toCommandValue(s)
54175475
.replace(/%/g, '%25')
54185476
.replace(/\r/g, '%0D')
54195477
.replace(/\n/g, '%0A');
54205478
}
54215479
function escapeProperty(s) {
5422-
return toCommandValue(s)
5480+
return utils_1.toCommandValue(s)
54235481
.replace(/%/g, '%25')
54245482
.replace(/\r/g, '%0D')
54255483
.replace(/\n/g, '%0A')
@@ -6173,6 +6231,12 @@ function convertBody(buffer, headers) {
61736231
// html4
61746232
if (!res && str) {
61756233
res = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(str);
6234+
if (!res) {
6235+
res = /<meta[\s]+?content=(['"])(.+?)\1[\s]+?http-equiv=(['"])content-type\3/i.exec(str);
6236+
if (res) {
6237+
res.pop(); // drop last quote
6238+
}
6239+
}
61766240

61776241
if (res) {
61786242
res = /charset=(.*)/i.exec(res.pop());
@@ -7180,7 +7244,7 @@ function fetch(url, opts) {
71807244
// HTTP fetch step 5.5
71817245
switch (request.redirect) {
71827246
case 'error':
7183-
reject(new FetchError(`redirect mode is set to error: ${request.url}`, 'no-redirect'));
7247+
reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect'));
71847248
finalize();
71857249
return;
71867250
case 'manual':
@@ -7219,7 +7283,8 @@ function fetch(url, opts) {
72197283
method: request.method,
72207284
body: request.body,
72217285
signal: request.signal,
7222-
timeout: request.timeout
7286+
timeout: request.timeout,
7287+
size: request.size
72237288
};
72247289

72257290
// HTTP-redirect fetch step 9
@@ -7835,6 +7900,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
78357900
};
78367901
Object.defineProperty(exports, "__esModule", { value: true });
78377902
const command_1 = __webpack_require__(431);
7903+
const file_command_1 = __webpack_require__(102);
7904+
const utils_1 = __webpack_require__(82);
78387905
const os = __importStar(__webpack_require__(87));
78397906
const path = __importStar(__webpack_require__(622));
78407907
/**
@@ -7861,9 +7928,17 @@ var ExitCode;
78617928
*/
78627929
// eslint-disable-next-line @typescript-eslint/no-explicit-any
78637930
function exportVariable(name, val) {
7864-
const convertedVal = command_1.toCommandValue(val);
7931+
const convertedVal = utils_1.toCommandValue(val);
78657932
process.env[name] = convertedVal;
7866-
command_1.issueCommand('set-env', { name }, convertedVal);
7933+
const filePath = process.env['GITHUB_ENV'] || '';
7934+
if (filePath) {
7935+
const delimiter = '_GitHubActionsFileCommandDelimeter_';
7936+
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
7937+
file_command_1.issueCommand('ENV', commandValue);
7938+
}
7939+
else {
7940+
command_1.issueCommand('set-env', { name }, convertedVal);
7941+
}
78677942
}
78687943
exports.exportVariable = exportVariable;
78697944
/**
@@ -7879,7 +7954,13 @@ exports.setSecret = setSecret;
78797954
* @param inputPath
78807955
*/
78817956
function addPath(inputPath) {
7882-
command_1.issueCommand('add-path', {}, inputPath);
7957+
const filePath = process.env['GITHUB_PATH'] || '';
7958+
if (filePath) {
7959+
file_command_1.issueCommand('PATH', inputPath);
7960+
}
7961+
else {
7962+
command_1.issueCommand('add-path', {}, inputPath);
7963+
}
78837964
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
78847965
}
78857966
exports.addPath = addPath;
@@ -15325,7 +15406,7 @@ module.exports = options => {
1532515406
/***/ 969:
1532615407
/***/ (function(module) {
1532715408

15328-
module.exports = {"_from":"signale@^1.4.0","_id":"[email protected]","_inBundle":false,"_integrity":"sha512-iuh+gPf28RkltuJC7W5MRi6XAjTDCAPC/prJUpQoG4vIP3MJZ+GTydVnodXA7pwvTKb2cA0m9OFZW/cdWy/I/w==","_location":"/signale","_phantomChildren":{},"_requested":{"type":"range","registry":true,"raw":"signale@^1.4.0","name":"signale","escapedName":"signale","rawSpec":"^1.4.0","saveSpec":null,"fetchSpec":"^1.4.0"},"_requiredBy":["/actions-toolkit"],"_resolved":"https://registry.npmjs.org/signale/-/signale-1.4.0.tgz","_shasum":"c4be58302fb0262ac00fc3d886a7c113759042f1","_spec":"signale@^1.4.0","_where":"/Users/jamesgeorge007/CodeSpace/scripting/JavaScript/GitHub-Actions/github-activity-readme/node_modules/actions-toolkit","author":{"name":"Klaus Sinani","email":"[email protected]","url":"https://klaussinani.github.io"},"bugs":{"url":"https://github.com/klaussinani/signale/issues"},"bundleDependencies":false,"dependencies":{"chalk":"^2.3.2","figures":"^2.0.0","pkg-conf":"^2.1.0"},"deprecated":false,"description":"👋 Hackable console logger","devDependencies":{"xo":"*"},"engines":{"node":">=6"},"files":["index.js","signale.js","types.js"],"homepage":"https://github.com/klaussinani/signale#readme","keywords":["hackable","colorful","console","logger"],"license":"MIT","maintainers":[{"name":"Mario Sinani","email":"[email protected]","url":"https://mariocfhq.github.io"}],"name":"signale","options":{"default":{"displayScope":true,"displayBadge":true,"displayDate":false,"displayFilename":false,"displayLabel":true,"displayTimestamp":false,"underlineLabel":true,"underlineMessage":false,"underlinePrefix":false,"underlineSuffix":false,"uppercaseLabel":false}},"repository":{"type":"git","url":"git+https://github.com/klaussinani/signale.git"},"scripts":{"test":"xo"},"version":"1.4.0","xo":{"space":2}};
15409+
module.exports = {"name":"signale","version":"1.4.0","description":"👋 Hackable console logger","license":"MIT","repository":"klaussinani/signale","author":{"name":"Klaus Sinani","email":"[email protected]","url":"https://klaussinani.github.io"},"maintainers":[{"name":"Mario Sinani","email":"[email protected]","url":"https://mariocfhq.github.io"}],"engines":{"node":">=6"},"files":["index.js","signale.js","types.js"],"keywords":["hackable","colorful","console","logger"],"scripts":{"test":"xo"},"dependencies":{"chalk":"^2.3.2","figures":"^2.0.0","pkg-conf":"^2.1.0"},"devDependencies":{"xo":"*"},"options":{"default":{"displayScope":true,"displayBadge":true,"displayDate":false,"displayFilename":false,"displayLabel":true,"displayTimestamp":false,"underlineLabel":true,"underlineMessage":false,"underlinePrefix":false,"underlineSuffix":false,"uppercaseLabel":false}},"xo":{"space":2}};
1532915410

1533015411
/***/ }),
1533115412

index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ const serializers = {
9898
: `${emoji} ${capitalize(item.payload.action)}`;
9999
return `${line} PR ${toUrlFormat(item)} in ${toUrlFormat(item.repo.name)}`;
100100
},
101+
ReleaseEvent: (item) => {
102+
return `🚀 ${capitalize(item.payload.action)} release ${toUrlFormat(
103+
item.payload.release.name
104+
? item.payload.release.name
105+
: item.payload.release.tag_name
106+
)} in ${toUrlFormat(item.repo.name)}`;
107+
},
101108
};
102109

103110
Toolkit.run(
@@ -140,7 +147,9 @@ Toolkit.run(
140147
);
141148

142149
if (!content.length) {
143-
tools.exit.failure("No PullRequest/Issue/IssueComment events found");
150+
tools.exit.failure(
151+
"No PullRequest/Issue/IssueComment/Release events found"
152+
);
144153
}
145154

146155
if (content.length < 5) {

0 commit comments

Comments
 (0)