Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add COMMIT_MSG input param #26

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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