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: make commit message configurable #39

Closed
wants to merge 1 commit into from
Closed
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
feat: make commit message configurable
  • Loading branch information
sukovanej committed Sep 14, 2022
commit 22ef4843a8548ef9b37a72aea31f9dc76a97f15a
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');
};