Skip to content

Commit

Permalink
feat: make commit message configurable (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
sukovanej authored Sep 15, 2022
1 parent 4f872c3 commit 321116c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ Jest coverage summary path (json-summary). Defining this may be useful if you ne

> Default value: **./coverage/coverage-summary.json**
### 🔶 `commit-message`

Commit message of the commit with generated badges.

> Default value: **Updating coverage badges**
## ⚡ Usage

Let's first define an npm script to run jest in package.json, specifying the coverage option to generate a coverage report:
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ inputs:
coverage-summary-path:
description: 'Jest coverage summary path (json-summary). Defining this may be useful if you need to run this action on a monorepo.'
default: './coverage/coverage-summary.json'
commit-message:
description: 'Commit message of the commit with generated badges.'
default: 'Updating coverage badges'

runs:
using: 'node12'
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/logic/git/pushBadges.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { getInput } from '@actions/core';
import { exec } from '@actions/exec';
import { mocked } from 'jest-mock';

import { pushBadges } from './pushBadges';

jest.mock('@actions/exec');
jest.mock('@actions/core');

describe('pushBadges function', () => {
beforeEach(() => jest.clearAllMocks());

it('should push changes', async () => {
mocked(getInput).mockReturnValueOnce('Updating coverage badges');

await pushBadges();

expect(exec).toHaveBeenCalledTimes(3);
Expand Down
3 changes: 2 additions & 1 deletion src/logic/git/pushBadges.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { getInput } from '@actions/core';
import { exec } from '@actions/exec';

export const pushBadges = async (): Promise<void> => {
await exec('git add', ['./badges']);
await exec('git commit', ['-m', 'Updating coverage badges']);
await exec('git commit', ['-m', getInput('commit-message')]);
await exec('git push');
};

0 comments on commit 321116c

Please sign in to comment.