Customization for commit message, committer name/email (#9)
This commit is contained in:
parent
fc6174a438
commit
560d9799e9
|
@ -65,6 +65,9 @@ Following inputs can be used as `step.with` keys
|
||||||
| `repo` | String | GitHub repository where assets will be deployed (default current) |
|
| `repo` | String | GitHub repository where assets will be deployed (default current) |
|
||||||
| `target_branch` | String | Git branch where assets will be deployed (default `gh-pages`) |
|
| `target_branch` | String | Git branch where assets will be deployed (default `gh-pages`) |
|
||||||
| `build_dir` | String | Build directory to deploy |
|
| `build_dir` | String | Build directory to deploy |
|
||||||
|
| `comitter_name` | String | Commit author's name |
|
||||||
|
| `comitter_email`| String | Commit author's email |
|
||||||
|
| `commit_message`| String | Commit message |
|
||||||
|
|
||||||
### environment variables
|
### environment variables
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,15 @@ inputs:
|
||||||
build_dir:
|
build_dir:
|
||||||
description: 'Build directory to deploy'
|
description: 'Build directory to deploy'
|
||||||
required: true
|
required: true
|
||||||
|
comitter_name:
|
||||||
|
description: 'Name of the commit author'
|
||||||
|
default: 'github-actions'
|
||||||
|
comitter_email:
|
||||||
|
description: 'Email of the commit author'
|
||||||
|
default: 'username@users.noreply.github.com'
|
||||||
|
commit_message:
|
||||||
|
description: 'Commit description'
|
||||||
|
default: 'Deploy to GitHub pages'
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
|
|
21
lib/main.js
21
lib/main.js
|
@ -17,16 +17,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const child_process = __importStar(require("child_process"));
|
const child_process = __importStar(require("child_process"));
|
||||||
const fs = __importStar(require("fs"));
|
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const exec = __importStar(require("@actions/exec"));
|
const exec = __importStar(require("@actions/exec"));
|
||||||
|
const fs = __importStar(require("fs"));
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const repo = core.getInput('repo') || process.env['GITHUB_REPOSITORY'] || '';
|
const repo = core.getInput('repo') || process.env['GITHUB_REPOSITORY'] || '';
|
||||||
const target_branch = core.getInput('target_branch') || 'gh-pages';
|
const target_branch = core.getInput('target_branch') || 'gh-pages';
|
||||||
const build_dir = core.getInput('build_dir', { required: true });
|
const build_dir = core.getInput('build_dir', { required: true });
|
||||||
const username = process.env['GITHUB_ACTOR'] || 'github-actions';
|
const username = core.getInput('comitter_name') ||
|
||||||
|
process.env['GITHUB_ACTOR'] ||
|
||||||
|
'github-actions';
|
||||||
|
const useremail = core.getInput('comitter_email') || `${username}@users.noreply.github.com`;
|
||||||
|
const commitmessage = core.getInput('commit_message') || 'Deploy to GitHub pages';
|
||||||
if (!fs.existsSync(build_dir)) {
|
if (!fs.existsSync(build_dir)) {
|
||||||
core.setFailed('⛔️ Build dir does not exist');
|
core.setFailed('⛔️ Build dir does not exist');
|
||||||
return;
|
return;
|
||||||
|
@ -35,11 +39,7 @@ function run() {
|
||||||
process.chdir(build_dir);
|
process.chdir(build_dir);
|
||||||
yield exec.exec('git', ['init']);
|
yield exec.exec('git', ['init']);
|
||||||
yield exec.exec('git', ['config', 'user.name', username]);
|
yield exec.exec('git', ['config', 'user.name', username]);
|
||||||
yield exec.exec('git', [
|
yield exec.exec('git', ['config', 'user.email', useremail]);
|
||||||
'config',
|
|
||||||
'user.email',
|
|
||||||
`${username}@users.noreply.github.com`
|
|
||||||
]);
|
|
||||||
try {
|
try {
|
||||||
child_process.execSync('git status --porcelain').toString();
|
child_process.execSync('git status --porcelain').toString();
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,7 @@ function run() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
yield exec.exec('git', ['add', '.']);
|
yield exec.exec('git', ['add', '.']);
|
||||||
yield exec.exec('git', [
|
yield exec.exec('git', ['commit', '--allow-empty', '-m', commitmessage]);
|
||||||
'commit',
|
|
||||||
'--allow-empty',
|
|
||||||
'-m',
|
|
||||||
'Deploy to GitHub pages'
|
|
||||||
]);
|
|
||||||
let gitURL = String('https://');
|
let gitURL = String('https://');
|
||||||
if (process.env['GITHUB_PAT']) {
|
if (process.env['GITHUB_PAT']) {
|
||||||
gitURL = gitURL.concat(process.env['GITHUB_PAT']);
|
gitURL = gitURL.concat(process.env['GITHUB_PAT']);
|
||||||
|
|
65
node_modules/@actions/core/package.json
generated
vendored
65
node_modules/@actions/core/package.json
generated
vendored
|
@ -1,40 +1,15 @@
|
||||||
{
|
{
|
||||||
"_args": [
|
"name": "@actions/core",
|
||||||
[
|
"version": "1.2.0",
|
||||||
"@actions/core@1.2.0",
|
|
||||||
"/home/runner/work/ghaction-github-pages/ghaction-github-pages"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "@actions/core@1.2.0",
|
|
||||||
"_id": "@actions/core@1.2.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-ZKdyhlSlyz38S6YFfPnyNgCDZuAF2T0Qv5eHflNWytPS8Qjvz39bZFMry9Bb/dpSnqWcNeav5yM2CTYpJeY+Dw==",
|
|
||||||
"_location": "/@actions/core",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "@actions/core@1.2.0",
|
|
||||||
"name": "@actions/core",
|
|
||||||
"escapedName": "@actions%2fcore",
|
|
||||||
"scope": "@actions",
|
|
||||||
"rawSpec": "1.2.0",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "1.2.0"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.0.tgz",
|
|
||||||
"_spec": "1.2.0",
|
|
||||||
"_where": "/home/runner/work/ghaction-github-pages/ghaction-github-pages",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/actions/toolkit/issues"
|
|
||||||
},
|
|
||||||
"description": "Actions core lib",
|
"description": "Actions core lib",
|
||||||
"devDependencies": {
|
"keywords": [
|
||||||
"@types/node": "^12.0.2"
|
"github",
|
||||||
},
|
"actions",
|
||||||
|
"core"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "lib/core.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
"lib": "lib",
|
"lib": "lib",
|
||||||
"test": "__tests__"
|
"test": "__tests__"
|
||||||
|
@ -42,15 +17,6 @@
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
|
|
||||||
"keywords": [
|
|
||||||
"github",
|
|
||||||
"actions",
|
|
||||||
"core"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "lib/core.js",
|
|
||||||
"name": "@actions/core",
|
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
@ -63,5 +29,14 @@
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||||
"tsc": "tsc"
|
"tsc": "tsc"
|
||||||
},
|
},
|
||||||
"version": "1.2.0"
|
"bugs": {
|
||||||
|
"url": "https://github.com/actions/toolkit/issues"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^12.0.2"
|
||||||
|
}
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.0.tgz"
|
||||||
|
,"_integrity": "sha512-ZKdyhlSlyz38S6YFfPnyNgCDZuAF2T0Qv5eHflNWytPS8Qjvz39bZFMry9Bb/dpSnqWcNeav5yM2CTYpJeY+Dw=="
|
||||||
|
,"_from": "@actions/core@1.2.0"
|
||||||
}
|
}
|
67
node_modules/@actions/exec/package.json
generated
vendored
67
node_modules/@actions/exec/package.json
generated
vendored
|
@ -1,40 +1,15 @@
|
||||||
{
|
{
|
||||||
"_args": [
|
"name": "@actions/exec",
|
||||||
[
|
"version": "1.0.1",
|
||||||
"@actions/exec@1.0.1",
|
|
||||||
"/home/runner/work/ghaction-github-pages/ghaction-github-pages"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
"_from": "@actions/exec@1.0.1",
|
|
||||||
"_id": "@actions/exec@1.0.1",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-nvFkxwiicvpzNiCBF4wFBDfnBvi7xp/as7LE1hBxBxKG2L29+gkIPBiLKMVORL+Hg3JNf07AKRfl0V5djoypjQ==",
|
|
||||||
"_location": "/@actions/exec",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "@actions/exec@1.0.1",
|
|
||||||
"name": "@actions/exec",
|
|
||||||
"escapedName": "@actions%2fexec",
|
|
||||||
"scope": "@actions",
|
|
||||||
"rawSpec": "1.0.1",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "1.0.1"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.1.tgz",
|
|
||||||
"_spec": "1.0.1",
|
|
||||||
"_where": "/home/runner/work/ghaction-github-pages/ghaction-github-pages",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/actions/toolkit/issues"
|
|
||||||
},
|
|
||||||
"description": "Actions exec lib",
|
"description": "Actions exec lib",
|
||||||
"devDependencies": {
|
"keywords": [
|
||||||
"@actions/io": "^1.0.1"
|
"github",
|
||||||
},
|
"actions",
|
||||||
|
"exec"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "lib/exec.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
"lib": "lib",
|
"lib": "lib",
|
||||||
"test": "__tests__"
|
"test": "__tests__"
|
||||||
|
@ -42,16 +17,6 @@
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
],
|
],
|
||||||
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52",
|
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
|
|
||||||
"keywords": [
|
|
||||||
"github",
|
|
||||||
"actions",
|
|
||||||
"exec"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "lib/exec.js",
|
|
||||||
"name": "@actions/exec",
|
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
@ -63,5 +28,15 @@
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||||
"tsc": "tsc"
|
"tsc": "tsc"
|
||||||
},
|
},
|
||||||
"version": "1.0.1"
|
"bugs": {
|
||||||
|
"url": "https://github.com/actions/toolkit/issues"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@actions/io": "^1.0.1"
|
||||||
|
},
|
||||||
|
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52"
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.1.tgz"
|
||||||
|
,"_integrity": "sha512-nvFkxwiicvpzNiCBF4wFBDfnBvi7xp/as7LE1hBxBxKG2L29+gkIPBiLKMVORL+Hg3JNf07AKRfl0V5djoypjQ=="
|
||||||
|
,"_from": "@actions/exec@1.0.1"
|
||||||
}
|
}
|
24
src/main.ts
24
src/main.ts
|
@ -1,7 +1,7 @@
|
||||||
import * as child_process from 'child_process';
|
import * as child_process from 'child_process';
|
||||||
import * as fs from 'fs';
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
|
@ -9,7 +9,14 @@ async function run() {
|
||||||
core.getInput('repo') || process.env['GITHUB_REPOSITORY'] || '';
|
core.getInput('repo') || process.env['GITHUB_REPOSITORY'] || '';
|
||||||
const target_branch = core.getInput('target_branch') || 'gh-pages';
|
const target_branch = core.getInput('target_branch') || 'gh-pages';
|
||||||
const build_dir = core.getInput('build_dir', {required: true});
|
const build_dir = core.getInput('build_dir', {required: true});
|
||||||
const username = process.env['GITHUB_ACTOR'] || 'github-actions';
|
const username =
|
||||||
|
core.getInput('comitter_name') ||
|
||||||
|
process.env['GITHUB_ACTOR'] ||
|
||||||
|
'github-actions';
|
||||||
|
const useremail =
|
||||||
|
core.getInput('comitter_email') || `${username}@users.noreply.github.com`;
|
||||||
|
const commitmessage =
|
||||||
|
core.getInput('commit_message') || 'Deploy to GitHub pages';
|
||||||
|
|
||||||
if (!fs.existsSync(build_dir)) {
|
if (!fs.existsSync(build_dir)) {
|
||||||
core.setFailed('⛔️ Build dir does not exist');
|
core.setFailed('⛔️ Build dir does not exist');
|
||||||
|
@ -23,11 +30,7 @@ async function run() {
|
||||||
process.chdir(build_dir);
|
process.chdir(build_dir);
|
||||||
await exec.exec('git', ['init']);
|
await exec.exec('git', ['init']);
|
||||||
await exec.exec('git', ['config', 'user.name', username]);
|
await exec.exec('git', ['config', 'user.name', username]);
|
||||||
await exec.exec('git', [
|
await exec.exec('git', ['config', 'user.email', useremail]);
|
||||||
'config',
|
|
||||||
'user.email',
|
|
||||||
`${username}@users.noreply.github.com`
|
|
||||||
]);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
child_process.execSync('git status --porcelain').toString();
|
child_process.execSync('git status --porcelain').toString();
|
||||||
|
@ -37,12 +40,7 @@ async function run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
await exec.exec('git', ['add', '.']);
|
await exec.exec('git', ['add', '.']);
|
||||||
await exec.exec('git', [
|
await exec.exec('git', ['commit', '--allow-empty', '-m', commitmessage]);
|
||||||
'commit',
|
|
||||||
'--allow-empty',
|
|
||||||
'-m',
|
|
||||||
'Deploy to GitHub pages'
|
|
||||||
]);
|
|
||||||
|
|
||||||
let gitURL = String('https://');
|
let gitURL = String('https://');
|
||||||
if (process.env['GITHUB_PAT']) {
|
if (process.env['GITHUB_PAT']) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user