Skip to content

Commit ad7e795

Browse files
Updated Commit Handler With Custom Commit Message & SKIP CI
1 parent 1144782 commit ad7e795

File tree

6 files changed

+74
-21
lines changed

6 files changed

+74
-21
lines changed

action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ inputs:
3636
description: "Whether or not you want to do a pull request. Only works when branch name is provided. Default false"
3737
required: false
3838
default: 'false'
39+
SKIP_CI:
40+
description: "Adds [skip ci] to commit message which will avoid running github actions in targer repository"
41+
required: false
42+
default: 'false'
43+
COMMIT_MESSAGE:
44+
description: "Provide your own custom commit MESSAGE"
45+
required: false
46+
default: 'false'
3947

4048
runs:
4149
using: 'node12'

dist/index.js

Lines changed: 45 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/helper.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,17 @@ const source_file_location = async( WORKFLOW_FILES_DIR, REPOSITORY_OWNER, REPOSI
140140
return _return;
141141
};
142142

143-
const commitfile = async( local_path ) => {
143+
const commitfile = async( local_path, skip_ci, commit_message ) => {
144144
let message = `💬 - Files Synced | Runner ID : ${toolkit.input.env( 'GITHUB_RUN_NUMBER' )} | ⚡ Triggered By ${toolkit.input.env( 'GITHUB_REPOSITORY' )}`;
145+
146+
if( typeof commit_message === 'undefined' && true === skip_ci ) {
147+
message = message + ' | [skip ci] ';
148+
}
149+
150+
if( typeof commit_message === 'string' && ( commit_message !== 'false' && commit_message !== 'true' ) ) {
151+
message = commit_message;
152+
}
153+
145154
return await toolkit.git.commit( local_path, message );
146155
};
147156

src/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ async function run() {
1515
let REPOSITORIES = require( './variables' ).REPOSITORIES;
1616
let WORKFLOW_FILES = require( './variables' ).WORKFLOW_FILES;
1717
let PULL_REQUEST = require( './variables' ).PULL_REQUEST;
18+
let SKIP_CI = require( './variables' ).SKIP_CI;
19+
let COMMIT_MESSAGE = require( './variables' ).COMMIT_MESSAGE;
1820

1921
toolkit.log( '-------------------------------------------------------' );
2022
toolkit.log( '⚙️ Basic Config' );
@@ -24,6 +26,8 @@ async function run() {
2426
toolkit.log( ` * DRY_RUN : ${DRY_RUN}` );
2527
toolkit.log( ` * WORKFLOW_FILES_DIR : ${WORKFLOW_FILES_DIR}` );
2628
toolkit.log( ` * WORKSPACE : ${WORKSPACE}` );
29+
toolkit.log( ` * SKIP_CI : ${SKIP_CI}` );
30+
toolkit.log( ` * COMMIT_MESSAGE : ${COMMIT_MESSAGE}` );
2731
toolkit.log( '-------------------------------------------------------' );
2832
toolkit.log( '' );
2933

@@ -112,7 +116,7 @@ async function run() {
112116
if( '' === haschange ) {
113117
toolkit.log.green( ' No changes detected' );
114118
} else if( false !== haschange ) {
115-
await helper.commitfile( local_path );
119+
await helper.commitfile( local_path, SKIP_CI, COMMIT_MESSAGE );
116120
modified.push( `${workflow_file.dest}` );
117121
}
118122
}
@@ -133,7 +137,7 @@ async function run() {
133137
if( '' === haschange && !COMMIT_EACH_FILE ) {
134138
toolkit.log.success( 'No Changes Are Done :', ' ' );
135139
} else if( false !== haschange && !COMMIT_EACH_FILE ) {
136-
await helper.commitfile( local_path );
140+
await helper.commitfile( local_path, SKIP_CI, COMMIT_MESSAGE );
137141
modified.push( local_path );
138142
}
139143

src/variables.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ const AUTO_CREATE_NEW_BRANCH = toolkit.input.tobool( core.getInput( 'AUTO_CREATE
55
const COMMIT_EACH_FILE = toolkit.input.tobool( core.getInput( 'COMMIT_EACH_FILE' ) );
66
const DRY_RUN = toolkit.input.tobool( core.getInput( 'DRY_RUN' ) );
77
const PULL_REQUEST = toolkit.input.tobool( core.getInput( 'PULL_REQUEST' ) );
8+
const SKIP_CI = toolkit.input.tobool( core.getInput( 'SKIP_CI' ) );
89
const GITHUB_TOKEN = core.getInput( 'GITHUB_TOKEN' );
910
const RAW_REPOSITORIES = core.getInput( 'REPOSITORIES' );
11+
const COMMIT_MESSAGE = core.getInput( 'COMMIT_MESSAGE' );
1012
const RAW_WORKFLOW_FILES = core.getInput( 'WORKFLOW_FILES' );
1113
const WORKFLOW_FILES_DIR = core.getInput( 'WORKFLOW_FILES_DIR' );
1214
const REPOSITORIES = RAW_REPOSITORIES.split( '\n' );
@@ -29,4 +31,6 @@ module.exports = {
2931
WORKFLOW_FILES,
3032
WORKSPACE,
3133
GITHUB_WORKSPACE,
34+
SKIP_CI,
35+
COMMIT_MESSAGE
3236
};

0 commit comments

Comments
 (0)