Skip to content

Commit

Permalink
Added the option to specify a custom commit message. (#26)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
akashgp09 and jamesgeorge007 authored Sep 3, 2020
1 parent bc6ff53 commit 03be176
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,29 @@ Please note that only those public events that belong to the following list show

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

### Custom commit message

One can specify a custom commit message with the `COMMIT_MSG` option.

```yml
name: Update README
on:
schedule:
- cron: '*/30 * * * *'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: jamesgeorge007/github-activity-readme@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
COMMIT_MSG: 'Specify a custom commit message'
```

_Inspired by [JasonEtco/activity-box](https://github.com/JasonEtco/activity-box)_
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ description: Updates README with the recent GitHub activity of a user
author: jamesgeorge007

inputs:
USERNAME:
GH_USERNAME:
description: 'Your GitHub username'
default: ${{ github.repository_owner }}
required: false
COMMIT_MSG:
description: "Commit message used while committing to the repo"
default: ":zap: Update README with the recent activity"
required: false

branding:
color: yellow
Expand Down
11 changes: 4 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,9 @@ const { Toolkit } = __webpack_require__(461);

const MAX_LINES = 5;

// Get config
const GH_USERNAME = core.getInput("GH_USERNAME");
const COMMIT_MSG = core.getInput("COMMIT_MSG");
/**
* Returns the sentence case representation
* @param {String} str - the string
Expand Down Expand Up @@ -1549,11 +1552,7 @@ const commitFile = async () => {
]);
await exec("git", ["config", "--global", "user.name", "readme-bot"]);
await exec("git", ["add", "README.md"]);
await exec("git", [
"commit",
"-m",
":zap: update readme with the recent activity",
]);
await exec("git", ["commit", "-m", COMMIT_MSG]);
await exec("git", ["push"]);
};

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

Toolkit.run(
async (tools) => {
const GH_USERNAME = core.getInput("USERNAME");

// Get the user's public events
tools.log.debug(`Getting activity for ${GH_USERNAME}`);
const events = await tools.github.activity.listPublicEventsForUser({
Expand Down
11 changes: 4 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const { Toolkit } = require("actions-toolkit");

const MAX_LINES = 5;

// Get config
const GH_USERNAME = core.getInput("GH_USERNAME");
const COMMIT_MSG = core.getInput("COMMIT_MSG");
/**
* Returns the sentence case representation
* @param {String} str - the string
Expand Down Expand Up @@ -74,11 +77,7 @@ const commitFile = async () => {
]);
await exec("git", ["config", "--global", "user.name", "readme-bot"]);
await exec("git", ["add", "README.md"]);
await exec("git", [
"commit",
"-m",
":zap: update readme with the recent activity",
]);
await exec("git", ["commit", "-m", COMMIT_MSG]);
await exec("git", ["push"]);
};

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

Toolkit.run(
async (tools) => {
const GH_USERNAME = core.getInput("USERNAME");

// Get the user's public events
tools.log.debug(`Getting activity for ${GH_USERNAME}`);
const events = await tools.github.activity.listPublicEventsForUser({
Expand Down

0 comments on commit 03be176

Please sign in to comment.