Skip to content

Commit 03be176

Browse files
Added the option to specify a custom commit message. (#26)
* Added option to specify a custom commit message. * Added action to specify a custom commit message. * Added Instruction to specify a custom commit message. * Updated Index.js * fix: ci * chore: update default commit message Co-authored-by: jamesgeorge007 <[email protected]>
1 parent bc6ff53 commit 03be176

File tree

4 files changed

+39
-15
lines changed

4 files changed

+39
-15
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,29 @@ Please note that only those public events that belong to the following list show
4444

4545
You can find an example [here](https://github.com/jamesgeorge007/jamesgeorge007/blob/master/.github/workflows/update-readme.yml).
4646

47+
### Custom commit message
48+
49+
One can specify a custom commit message with the `COMMIT_MSG` option.
50+
51+
```yml
52+
name: Update README
53+
54+
on:
55+
schedule:
56+
- cron: '*/30 * * * *'
57+
workflow_dispatch:
58+
59+
jobs:
60+
build:
61+
runs-on: ubuntu-latest
62+
63+
steps:
64+
- uses: actions/checkout@v2
65+
- uses: jamesgeorge007/github-activity-readme@master
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
with:
69+
COMMIT_MSG: 'Specify a custom commit message'
70+
```
71+
4772
_Inspired by [JasonEtco/activity-box](https://github.com/JasonEtco/activity-box)_

action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ description: Updates README with the recent GitHub activity of a user
33
author: jamesgeorge007
44

55
inputs:
6-
USERNAME:
6+
GH_USERNAME:
77
description: 'Your GitHub username'
88
default: ${{ github.repository_owner }}
9+
required: false
10+
COMMIT_MSG:
11+
description: "Commit message used while committing to the repo"
12+
default: ":zap: Update README with the recent activity"
13+
required: false
914

1015
branding:
1116
color: yellow

dist/index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,9 @@ const { Toolkit } = __webpack_require__(461);
14811481

14821482
const MAX_LINES = 5;
14831483

1484+
// Get config
1485+
const GH_USERNAME = core.getInput("GH_USERNAME");
1486+
const COMMIT_MSG = core.getInput("COMMIT_MSG");
14841487
/**
14851488
* Returns the sentence case representation
14861489
* @param {String} str - the string
@@ -1549,11 +1552,7 @@ const commitFile = async () => {
15491552
]);
15501553
await exec("git", ["config", "--global", "user.name", "readme-bot"]);
15511554
await exec("git", ["add", "README.md"]);
1552-
await exec("git", [
1553-
"commit",
1554-
"-m",
1555-
":zap: update readme with the recent activity",
1556-
]);
1555+
await exec("git", ["commit", "-m", COMMIT_MSG]);
15571556
await exec("git", ["push"]);
15581557
};
15591558

@@ -1579,8 +1578,6 @@ const serializers = {
15791578

15801579
Toolkit.run(
15811580
async (tools) => {
1582-
const GH_USERNAME = core.getInput("USERNAME");
1583-
15841581
// Get the user's public events
15851582
tools.log.debug(`Getting activity for ${GH_USERNAME}`);
15861583
const events = await tools.github.activity.listPublicEventsForUser({

index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const { Toolkit } = require("actions-toolkit");
66

77
const MAX_LINES = 5;
88

9+
// Get config
10+
const GH_USERNAME = core.getInput("GH_USERNAME");
11+
const COMMIT_MSG = core.getInput("COMMIT_MSG");
912
/**
1013
* Returns the sentence case representation
1114
* @param {String} str - the string
@@ -74,11 +77,7 @@ const commitFile = async () => {
7477
]);
7578
await exec("git", ["config", "--global", "user.name", "readme-bot"]);
7679
await exec("git", ["add", "README.md"]);
77-
await exec("git", [
78-
"commit",
79-
"-m",
80-
":zap: update readme with the recent activity",
81-
]);
80+
await exec("git", ["commit", "-m", COMMIT_MSG]);
8281
await exec("git", ["push"]);
8382
};
8483

@@ -104,8 +103,6 @@ const serializers = {
104103

105104
Toolkit.run(
106105
async (tools) => {
107-
const GH_USERNAME = core.getInput("USERNAME");
108-
109106
// Get the user's public events
110107
tools.log.debug(`Getting activity for ${GH_USERNAME}`);
111108
const events = await tools.github.activity.listPublicEventsForUser({

0 commit comments

Comments
 (0)