From 21d9a864ea8f6031b1a5651933187b8ed14266f3 Mon Sep 17 00:00:00 2001 From: Lorenzo <69311874+Lorenzo0111@users.noreply.github.com> Date: Fri, 14 May 2021 17:51:30 +0200 Subject: [PATCH] Add custom committer name and email Co-authored-by: Jan Larwig --- README.md | 17 ++++++++--------- action.yml | 10 +++++++++- dist/index.js | 13 +++++-------- index.js | 11 ++++------- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index ba4822d..b7f8178 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,10 @@ Updates `README.md` with the recent GitHub activity of a user. ```yml name: Update README - on: schedule: - cron: "*/30 * * * *" workflow_dispatch: - jobs: build: name: Update this repo's README with recent activity @@ -51,20 +49,20 @@ You can find an example [here](https://github.com/jamesgeorge007/jamesgeorge007/ Use the following `input params` to customize it for your use case:- -| Input Param | Default Value | Description | -| ------------- | -------------------------------------------- | --------------------------------------------------------- | -| `COMMIT_MSG` | :zap: Update README with the recent activity | Commit message used while committing to the repo | -| `MAX_LINES` | 5 | The maximum number of lines populated in your readme file | -| `TARGET_FILE` | README.md | The file to insert recent activity into | +| Input Param | Default Value | Description | +| -------------- | ----------------------------------------------------- | --------------------------------------------------------- | +| `COMMIT_NAME` | github-actions[bot] | Name of the committer | +| `COMMIT_EMAIL` | 41898282+github-actions[bot]@users.noreply.github.com | Email of the committer | +| `COMMIT_MSG` | :zap: Update README with the recent activity | Commit message used while committing to the repo | +| `MAX_LINES` | 5 | The maximum number of lines populated in your readme file | +| `TARGET_FILE` | README.md | The file to insert recent activity into | ```yml name: Update README - on: schedule: - cron: "*/30 * * * *" workflow_dispatch: - jobs: build: name: Update this repo's README with recent activity @@ -80,6 +78,7 @@ jobs: with: COMMIT_MSG: "Specify a custom commit message" MAX_LINES: 10 + COMMIT_NAME: GitHub Activity Readme ``` _Inspired by [JasonEtco/activity-box](https://github.com/JasonEtco/activity-box)_ diff --git a/action.yml b/action.yml index 70401f7..7f18286 100644 --- a/action.yml +++ b/action.yml @@ -4,9 +4,17 @@ author: jamesgeorge007 inputs: GH_USERNAME: - description: 'Your GitHub username' + description: "Your GitHub username" default: ${{ github.repository_owner }} required: false + COMMIT_NAME: + description: "Name of the committer" + default: "github-actions[bot]" + required: false + COMMIT_EMAIL: + description: "Email of the committer" + default: "41898282+github-actions[bot]@users.noreply.github.com" + required: false COMMIT_MSG: description: "Commit message used while committing to the repo" default: ":zap: Update README with the recent activity" diff --git a/dist/index.js b/dist/index.js index 5935f51..8c9fc9c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1789,9 +1789,11 @@ const { Toolkit } = __webpack_require__(461); // Get config const GH_USERNAME = core.getInput("GH_USERNAME"); +const COMMIT_NAME = core.getInput("COMMIT_NAME"); +const COMMIT_EMAIL = core.getInput("COMMIT_EMAIL"); const COMMIT_MSG = core.getInput("COMMIT_MSG"); const MAX_LINES = core.getInput("MAX_LINES"); -const TARGET_FILE = core.getInput("TARGET_FILE") || "README.md"; +const TARGET_FILE = core.getInput("TARGET_FILE"); /** * Returns the sentence case representation @@ -1853,13 +1855,8 @@ const exec = (cmd, args = []) => */ const commitFile = async () => { - await exec("git", [ - "config", - "--global", - "user.email", - "41898282+github-actions[bot]@users.noreply.github.com", - ]); - await exec("git", ["config", "--global", "user.name", "readme-bot"]); + await exec("git", ["config", "--global", "user.email", COMMIT_EMAIL]); + await exec("git", ["config", "--global", "user.name", COMMIT_NAME]); await exec("git", ["add", TARGET_FILE]); await exec("git", ["commit", "-m", COMMIT_MSG]); await exec("git", ["push"]); diff --git a/index.js b/index.js index a9d5c5b..6b63690 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,8 @@ const { Toolkit } = require("actions-toolkit"); // Get config const GH_USERNAME = core.getInput("GH_USERNAME"); +const COMMIT_NAME = core.getInput("COMMIT_NAME"); +const COMMIT_EMAIL = core.getInput("COMMIT_EMAIL"); const COMMIT_MSG = core.getInput("COMMIT_MSG"); const MAX_LINES = core.getInput("MAX_LINES"); const TARGET_FILE = core.getInput("TARGET_FILE"); @@ -70,13 +72,8 @@ const exec = (cmd, args = []) => */ const commitFile = async () => { - await exec("git", [ - "config", - "--global", - "user.email", - "41898282+github-actions[bot]@users.noreply.github.com", - ]); - await exec("git", ["config", "--global", "user.name", "readme-bot"]); + await exec("git", ["config", "--global", "user.email", COMMIT_EMAIL]); + await exec("git", ["config", "--global", "user.name", COMMIT_NAME]); await exec("git", ["add", TARGET_FILE]); await exec("git", ["commit", "-m", COMMIT_MSG]); await exec("git", ["push"]);