Skip to content

Commit 21d9a86

Browse files
Lorenzo0111tuunit
andcommitted
Add custom committer name and email
Co-authored-by: Jan Larwig <[email protected]>
1 parent bfb65a4 commit 21d9a86

File tree

4 files changed

+26
-25
lines changed

4 files changed

+26
-25
lines changed

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ Updates `README.md` with the recent GitHub activity of a user.
1616

1717
```yml
1818
name: Update README
19-
2019
on:
2120
schedule:
2221
- cron: "*/30 * * * *"
2322
workflow_dispatch:
24-
2523
jobs:
2624
build:
2725
name: Update this repo's README with recent activity
@@ -51,20 +49,20 @@ You can find an example [here](https://github.com/jamesgeorge007/jamesgeorge007/
5149

5250
Use the following `input params` to customize it for your use case:-
5351

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 |
58-
| `TARGET_FILE` | README.md | The file to insert recent activity into |
52+
| Input Param | Default Value | Description |
53+
| -------------- | ----------------------------------------------------- | --------------------------------------------------------- |
54+
| `COMMIT_NAME` | github-actions[bot] | Name of the committer |
55+
| `COMMIT_EMAIL` | 41898282+github-actions[bot]@users.noreply.github.com | Email of the committer |
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 |
58+
| `TARGET_FILE` | README.md | The file to insert recent activity into |
5959

6060
```yml
6161
name: Update README
62-
6362
on:
6463
schedule:
6564
- cron: "*/30 * * * *"
6665
workflow_dispatch:
67-
6866
jobs:
6967
build:
7068
name: Update this repo's README with recent activity
@@ -80,6 +78,7 @@ jobs:
8078
with:
8179
COMMIT_MSG: "Specify a custom commit message"
8280
MAX_LINES: 10
81+
COMMIT_NAME: GitHub Activity Readme
8382
```
8483

8584
_Inspired by [JasonEtco/activity-box](https://github.com/JasonEtco/activity-box)_

action.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@ author: jamesgeorge007
44

55
inputs:
66
GH_USERNAME:
7-
description: 'Your GitHub username'
7+
description: "Your GitHub username"
88
default: ${{ github.repository_owner }}
99
required: false
10+
COMMIT_NAME:
11+
description: "Name of the committer"
12+
default: "github-actions[bot]"
13+
required: false
14+
COMMIT_EMAIL:
15+
description: "Email of the committer"
16+
default: "41898282+github-actions[bot]@users.noreply.github.com"
17+
required: false
1018
COMMIT_MSG:
1119
description: "Commit message used while committing to the repo"
1220
default: ":zap: Update README with the recent activity"

dist/index.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,9 +1789,11 @@ const { Toolkit } = __webpack_require__(461);
17891789

17901790
// Get config
17911791
const GH_USERNAME = core.getInput("GH_USERNAME");
1792+
const COMMIT_NAME = core.getInput("COMMIT_NAME");
1793+
const COMMIT_EMAIL = core.getInput("COMMIT_EMAIL");
17921794
const COMMIT_MSG = core.getInput("COMMIT_MSG");
17931795
const MAX_LINES = core.getInput("MAX_LINES");
1794-
const TARGET_FILE = core.getInput("TARGET_FILE") || "README.md";
1796+
const TARGET_FILE = core.getInput("TARGET_FILE");
17951797

17961798
/**
17971799
* Returns the sentence case representation
@@ -1853,13 +1855,8 @@ const exec = (cmd, args = []) =>
18531855
*/
18541856

18551857
const commitFile = async () => {
1856-
await exec("git", [
1857-
"config",
1858-
"--global",
1859-
"user.email",
1860-
"41898282+github-actions[bot]@users.noreply.github.com",
1861-
]);
1862-
await exec("git", ["config", "--global", "user.name", "readme-bot"]);
1858+
await exec("git", ["config", "--global", "user.email", COMMIT_EMAIL]);
1859+
await exec("git", ["config", "--global", "user.name", COMMIT_NAME]);
18631860
await exec("git", ["add", TARGET_FILE]);
18641861
await exec("git", ["commit", "-m", COMMIT_MSG]);
18651862
await exec("git", ["push"]);

index.js

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

77
// Get config
88
const GH_USERNAME = core.getInput("GH_USERNAME");
9+
const COMMIT_NAME = core.getInput("COMMIT_NAME");
10+
const COMMIT_EMAIL = core.getInput("COMMIT_EMAIL");
911
const COMMIT_MSG = core.getInput("COMMIT_MSG");
1012
const MAX_LINES = core.getInput("MAX_LINES");
1113
const TARGET_FILE = core.getInput("TARGET_FILE");
@@ -70,13 +72,8 @@ const exec = (cmd, args = []) =>
7072
*/
7173

7274
const commitFile = async () => {
73-
await exec("git", [
74-
"config",
75-
"--global",
76-
"user.email",
77-
"41898282+github-actions[bot]@users.noreply.github.com",
78-
]);
79-
await exec("git", ["config", "--global", "user.name", "readme-bot"]);
75+
await exec("git", ["config", "--global", "user.email", COMMIT_EMAIL]);
76+
await exec("git", ["config", "--global", "user.name", COMMIT_NAME]);
8077
await exec("git", ["add", TARGET_FILE]);
8178
await exec("git", ["commit", "-m", COMMIT_MSG]);
8279
await exec("git", ["push"]);

0 commit comments

Comments
 (0)