Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81f05c5524 | ||
|
|
60edcea535 | ||
|
|
2fa0a59e21 | ||
|
|
d1f987783c | ||
|
|
0466bfb243 | ||
|
|
a228296ccf | ||
|
|
77664235e1 | ||
|
|
a1ff787715 | ||
|
|
b2788ae3c6 | ||
|
|
680198766b | ||
|
|
7f32718f66 | ||
|
|
0404476337 |
16
.github/workflows/stale.yml
vendored
16
.github/workflows/stale.yml
vendored
@@ -2,16 +2,16 @@ name: "Stale"
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "6 6 * * *"
|
- cron: "6 6 * * *"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
stale:
|
stale:
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@v1
|
- uses: actions/stale@v1
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
stale-issue-message: 'This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
|
stale-issue-message: 'This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
|
||||||
stale-pr-message: 'This pull request is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
|
stale-pr-message: 'This pull request is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
|
||||||
days-before-stale: 21
|
days-before-stale: 21
|
||||||
days-before-close: 7
|
days-before-close: 7
|
||||||
|
|||||||
28
CHANGELOG.md
28
CHANGELOG.md
@@ -2,6 +2,34 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
## [3.5.3](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.2...v3.5.3) (2020-03-13)
|
||||||
|
|
||||||
|
|
||||||
|
### deps
|
||||||
|
|
||||||
|
* [security] bump acorn from 6.4.0 to 6.4.1 (#155) ([2fa0a59](https://github.com/peaceiris/actions-gh-pages/commit/2fa0a59e21f19c0862ebc505187b3ede95a92561)), closes [#155](https://github.com/peaceiris/actions-gh-pages/issues/155)
|
||||||
|
* bump @types/node from 12.12.29 to 12.12.30 (#154) ([d1f9877](https://github.com/peaceiris/actions-gh-pages/commit/d1f987783c05614c72b8c5009fbfd941982128ec)), closes [#154](https://github.com/peaceiris/actions-gh-pages/issues/154)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [3.5.2](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.1...v3.5.2) (2020-03-12)
|
||||||
|
|
||||||
|
|
||||||
|
### chore
|
||||||
|
|
||||||
|
* reindent ([b2788ae](https://github.com/peaceiris/actions-gh-pages/commit/b2788ae3c6c463fccde4f9db8abac12cf2f42b72))
|
||||||
|
|
||||||
|
### deps
|
||||||
|
|
||||||
|
* bump @typescript-eslint/eslint-plugin from 2.22.0 to 2.23.0 (#150) ([7f32718](https://github.com/peaceiris/actions-gh-pages/commit/7f32718f667956be6bab3cd2dffe9559cdd26fc7)), closes [#150](https://github.com/peaceiris/actions-gh-pages/issues/150)
|
||||||
|
* bump @typescript-eslint/parser from 2.22.0 to 2.23.0 (#149) ([6801987](https://github.com/peaceiris/actions-gh-pages/commit/680198766bcc7c4625ee5c9f599187f99bf0c118)), closes [#149](https://github.com/peaceiris/actions-gh-pages/issues/149)
|
||||||
|
|
||||||
|
### fix
|
||||||
|
|
||||||
|
* set commit author as local config (#152) ([a1ff787](https://github.com/peaceiris/actions-gh-pages/commit/a1ff787715905a17a17d1ab7b42eba976a4553c6)), closes [#152](https://github.com/peaceiris/actions-gh-pages/issues/152) [#151](https://github.com/peaceiris/actions-gh-pages/issues/151)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [3.5.1](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.0...v3.5.1) (2020-03-09)
|
## [3.5.1](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.0...v3.5.1) (2020-03-09)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
116
__tests__/git-utils.test.ts
Normal file
116
__tests__/git-utils.test.ts
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
import {getUserName, getUserEmail, setCommitAuthor} from '../src/git-utils';
|
||||||
|
import {getWorkDirName, createWorkDir} from '../src/utils';
|
||||||
|
import {CmdResult} from '../src/interfaces';
|
||||||
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
process.env['GITHUB_ACTOR'] = 'default-octocat';
|
||||||
|
process.env['GITHUB_REPOSITORY'] = 'owner/repo';
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
delete process.env['GITHUB_ACTOR'];
|
||||||
|
delete process.env['GITHUB_REPOSITORY'];
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getUserName()', () => {
|
||||||
|
test('get default git user name', () => {
|
||||||
|
const userName = '';
|
||||||
|
const test = getUserName(userName);
|
||||||
|
expect(test).toMatch('default-octocat');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('get custom git user name', () => {
|
||||||
|
const userName = 'custom-octocat';
|
||||||
|
const test = getUserName(userName);
|
||||||
|
expect(test).toMatch(userName);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getUserEmail()', () => {
|
||||||
|
test('get default git user email', () => {
|
||||||
|
const userEmail = '';
|
||||||
|
const test = getUserEmail(userEmail);
|
||||||
|
expect(test).toMatch('default-octocat@users.noreply.github.com');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('get custom git user email', () => {
|
||||||
|
const userEmail = 'custom-octocat@github.com';
|
||||||
|
const test = getUserEmail(userEmail);
|
||||||
|
expect(test).toMatch(userEmail);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('setCommitAuthor()', () => {
|
||||||
|
let workDirName = '';
|
||||||
|
(async (): Promise<void> => {
|
||||||
|
const date = new Date();
|
||||||
|
const unixTime = date.getTime();
|
||||||
|
workDirName = await getWorkDirName(`${unixTime}`);
|
||||||
|
})();
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await createWorkDir(workDirName);
|
||||||
|
process.chdir(workDirName);
|
||||||
|
await exec.exec('git', ['init']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('get default commit author', async () => {
|
||||||
|
const userName = '';
|
||||||
|
const userEmail = '';
|
||||||
|
const result: CmdResult = {
|
||||||
|
exitcode: 0,
|
||||||
|
output: ''
|
||||||
|
};
|
||||||
|
const options = {
|
||||||
|
listeners: {
|
||||||
|
stdout: (data: Buffer): void => {
|
||||||
|
result.output += data.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await setCommitAuthor(userName, userEmail);
|
||||||
|
result.exitcode = await exec.exec('git', ['config', 'user.name'], options);
|
||||||
|
expect(result.output).toMatch('default-octocat');
|
||||||
|
result.exitcode = await exec.exec('git', ['config', 'user.email'], options);
|
||||||
|
expect(result.output).toMatch('default-octocat@users.noreply.github.com');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('get custom commit author', async () => {
|
||||||
|
const userName = 'custom-octocat';
|
||||||
|
const userEmail = 'custom-octocat@github.com';
|
||||||
|
const result: CmdResult = {
|
||||||
|
exitcode: 0,
|
||||||
|
output: ''
|
||||||
|
};
|
||||||
|
const options = {
|
||||||
|
listeners: {
|
||||||
|
stdout: (data: Buffer): void => {
|
||||||
|
result.output += data.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await setCommitAuthor(userName, userEmail);
|
||||||
|
result.exitcode = await exec.exec('git', ['config', 'user.name'], options);
|
||||||
|
expect(result.output).toMatch(userName);
|
||||||
|
result.exitcode = await exec.exec('git', ['config', 'user.email'], options);
|
||||||
|
expect(result.output).toMatch(userEmail);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('throw error user_email is undefined', async () => {
|
||||||
|
const userName = 'custom-octocat';
|
||||||
|
const userEmail = '';
|
||||||
|
await expect(setCommitAuthor(userName, userEmail)).rejects.toThrowError(
|
||||||
|
'user_email is undefined'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('throw error user_name is undefined', async () => {
|
||||||
|
const userName = '';
|
||||||
|
const userEmail = 'custom-octocat@github.com';
|
||||||
|
await expect(setCommitAuthor(userName, userEmail)).rejects.toThrowError(
|
||||||
|
'user_name is undefined'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
56
lib/index.js
56
lib/index.js
@@ -2251,20 +2251,19 @@ const core = __importStar(__webpack_require__(470));
|
|||||||
const exec = __importStar(__webpack_require__(986));
|
const exec = __importStar(__webpack_require__(986));
|
||||||
const get_inputs_1 = __webpack_require__(452);
|
const get_inputs_1 = __webpack_require__(452);
|
||||||
const set_tokens_1 = __webpack_require__(615);
|
const set_tokens_1 = __webpack_require__(615);
|
||||||
const git = __importStar(__webpack_require__(496));
|
const git_utils_1 = __webpack_require__(496);
|
||||||
const utils_1 = __webpack_require__(163);
|
const utils_1 = __webpack_require__(163);
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const inps = get_inputs_1.getInputs();
|
const inps = get_inputs_1.getInputs();
|
||||||
get_inputs_1.showInputs(inps);
|
get_inputs_1.showInputs(inps);
|
||||||
yield git.setConfig(inps.UserName, inps.UserEmail);
|
|
||||||
const remoteURL = yield set_tokens_1.setTokens(inps);
|
const remoteURL = yield set_tokens_1.setTokens(inps);
|
||||||
core.debug(`[INFO] remoteURL: ${remoteURL}`);
|
core.debug(`[INFO] remoteURL: ${remoteURL}`);
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const unixTime = date.getTime();
|
const unixTime = date.getTime();
|
||||||
const workDir = yield utils_1.getWorkDirName(`${unixTime}`);
|
const workDir = yield utils_1.getWorkDirName(`${unixTime}`);
|
||||||
yield git.setRepo(inps, remoteURL, workDir);
|
yield git_utils_1.setRepo(inps, remoteURL, workDir);
|
||||||
yield utils_1.addNoJekyll(workDir, inps.DisableNoJekyll, inps.PublishBranch);
|
yield utils_1.addNoJekyll(workDir, inps.DisableNoJekyll, inps.PublishBranch);
|
||||||
yield utils_1.addCNAME(workDir, inps.CNAME);
|
yield utils_1.addCNAME(workDir, inps.CNAME);
|
||||||
try {
|
try {
|
||||||
@@ -2275,9 +2274,10 @@ function run() {
|
|||||||
}
|
}
|
||||||
yield exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
|
yield exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
|
||||||
yield exec.exec('git', ['add', '--all']);
|
yield exec.exec('git', ['add', '--all']);
|
||||||
yield git.commit(inps.AllowEmptyCommit, inps.ExternalRepository, inps.CommitMessage);
|
yield git_utils_1.setCommitAuthor(inps.UserName, inps.UserEmail);
|
||||||
yield git.push(inps.PublishBranch, inps.ForceOrphan);
|
yield git_utils_1.commit(inps.AllowEmptyCommit, inps.ExternalRepository, inps.CommitMessage);
|
||||||
yield git.pushTag(inps.TagName, inps.TagMessage);
|
yield git_utils_1.push(inps.PublishBranch, inps.ForceOrphan);
|
||||||
|
yield git_utils_1.pushTag(inps.TagName, inps.TagMessage);
|
||||||
core.info('[INFO] Action successfully completed');
|
core.info('[INFO] Action successfully completed');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -8519,29 +8519,37 @@ function setRepo(inps, remoteURL, workDir) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.setRepo = setRepo;
|
exports.setRepo = setRepo;
|
||||||
function setConfig(userName, userEmail) {
|
function getUserName(userName) {
|
||||||
|
if (userName) {
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return `${process.env.GITHUB_ACTOR}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.getUserName = getUserName;
|
||||||
|
function getUserEmail(userEmail) {
|
||||||
|
if (userEmail) {
|
||||||
|
return userEmail;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return `${process.env.GITHUB_ACTOR}@users.noreply.github.com`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.getUserEmail = getUserEmail;
|
||||||
|
function setCommitAuthor(userName, userEmail) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield exec.exec('git', ['config', '--global', 'gc.auto', '0']);
|
if (userName && !userEmail) {
|
||||||
let name = '';
|
throw new Error('user_email is undefined');
|
||||||
if (userName) {
|
|
||||||
name = userName;
|
|
||||||
}
|
}
|
||||||
else {
|
if (!userName && userEmail) {
|
||||||
name = `${process.env.GITHUB_ACTOR}`;
|
throw new Error('user_name is undefined');
|
||||||
}
|
}
|
||||||
yield exec.exec('git', ['config', '--global', 'user.name', name]);
|
yield exec.exec('git', ['config', 'user.name', getUserName(userName)]);
|
||||||
let email = '';
|
yield exec.exec('git', ['config', 'user.email', getUserEmail(userEmail)]);
|
||||||
if (userName !== '' && userEmail !== '') {
|
|
||||||
email = userEmail;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
email = `${process.env.GITHUB_ACTOR}@users.noreply.github.com`;
|
|
||||||
}
|
|
||||||
yield exec.exec('git', ['config', '--global', 'user.email', email]);
|
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.setConfig = setConfig;
|
exports.setCommitAuthor = setCommitAuthor;
|
||||||
function commit(allowEmptyCommit, externalRepository, message) {
|
function commit(allowEmptyCommit, externalRepository, message) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let msg = '';
|
let msg = '';
|
||||||
|
|||||||
66
package-lock.json
generated
66
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "actions-github-pages",
|
"name": "actions-github-pages",
|
||||||
"version": "3.5.1",
|
"version": "3.5.3",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -762,9 +762,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "12.12.29",
|
"version": "12.12.30",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.29.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.30.tgz",
|
||||||
"integrity": "sha512-yo8Qz0ygADGFptISDj3pOC9wXfln/5pQaN/ysDIzOaAWXt73cNHmtEC8zSO2Y+kse/txmwIAJzkYZ5fooaS5DQ=="
|
"integrity": "sha512-sz9MF/zk6qVr3pAnM0BSQvYIBK44tS75QC5N+VbWSE4DjCV/pJ+UzCW/F+vVnl7TkOPcuwQureKNtSSwjBTaMg=="
|
||||||
},
|
},
|
||||||
"@types/parse-json": {
|
"@types/parse-json": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
@@ -794,12 +794,12 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@typescript-eslint/eslint-plugin": {
|
"@typescript-eslint/eslint-plugin": {
|
||||||
"version": "2.22.0",
|
"version": "2.23.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.22.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.23.0.tgz",
|
||||||
"integrity": "sha512-BvxRLaTDVQ3N+Qq8BivLiE9akQLAOUfxNHIEhedOcg8B2+jY8Rc4/D+iVprvuMX1AdezFYautuGDwr9QxqSxBQ==",
|
"integrity": "sha512-8iA4FvRsz8qTjR0L/nK9RcRUN3QtIHQiOm69FzV7WS3SE+7P7DyGGwh3k4UNR2JBbk+Ej2Io+jLAaqKibNhmtw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@typescript-eslint/experimental-utils": "2.22.0",
|
"@typescript-eslint/experimental-utils": "2.23.0",
|
||||||
"eslint-utils": "^1.4.3",
|
"eslint-utils": "^1.4.3",
|
||||||
"functional-red-black-tree": "^1.0.1",
|
"functional-red-black-tree": "^1.0.1",
|
||||||
"regexpp": "^3.0.0",
|
"regexpp": "^3.0.0",
|
||||||
@@ -807,20 +807,20 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/experimental-utils": {
|
"@typescript-eslint/experimental-utils": {
|
||||||
"version": "2.22.0",
|
"version": "2.23.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.22.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.23.0.tgz",
|
||||||
"integrity": "sha512-sJt1GYBe6yC0dWOQzXlp+tiuGglNhJC9eXZeC8GBVH98Zv9jtatccuhz0OF5kC/DwChqsNfghHx7OlIDQjNYAQ==",
|
"integrity": "sha512-OswxY59RcXH3NNPmq+4Kis2CYZPurRU6mG5xPcn24CjFyfdVli5mySwZz/g/xDbJXgDsYqNGq7enV0IziWGXVQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/json-schema": "^7.0.3",
|
"@types/json-schema": "^7.0.3",
|
||||||
"@typescript-eslint/typescript-estree": "2.22.0",
|
"@typescript-eslint/typescript-estree": "2.23.0",
|
||||||
"eslint-scope": "^5.0.0"
|
"eslint-scope": "^5.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@typescript-eslint/typescript-estree": {
|
"@typescript-eslint/typescript-estree": {
|
||||||
"version": "2.22.0",
|
"version": "2.23.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.22.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.23.0.tgz",
|
||||||
"integrity": "sha512-2HFZW2FQc4MhIBB8WhDm9lVFaBDy6h9jGrJ4V2Uzxe/ON29HCHBTj3GkgcsgMWfsl2U5as+pTOr30Nibaw7qRQ==",
|
"integrity": "sha512-pmf7IlmvXdlEXvE/JWNNJpEvwBV59wtJqA8MLAxMKLXNKVRC3HZBXR/SlZLPWTCcwOSg9IM7GeRSV3SIerGVqw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
@@ -852,32 +852,32 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@typescript-eslint/parser": {
|
"@typescript-eslint/parser": {
|
||||||
"version": "2.22.0",
|
"version": "2.23.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.22.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.23.0.tgz",
|
||||||
"integrity": "sha512-FaZKC1X+nvD7qMPqKFUYHz3H0TAioSVFGvG29f796Nc5tBluoqfHgLbSFKsh7mKjRoeTm8J9WX2Wo9EyZWjG7w==",
|
"integrity": "sha512-k61pn/Nepk43qa1oLMiyqApC6x5eP5ddPz6VUYXCAuXxbmRLqkPYzkFRKl42ltxzB2luvejlVncrEpflgQoSUg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/eslint-visitor-keys": "^1.0.0",
|
"@types/eslint-visitor-keys": "^1.0.0",
|
||||||
"@typescript-eslint/experimental-utils": "2.22.0",
|
"@typescript-eslint/experimental-utils": "2.23.0",
|
||||||
"@typescript-eslint/typescript-estree": "2.22.0",
|
"@typescript-eslint/typescript-estree": "2.23.0",
|
||||||
"eslint-visitor-keys": "^1.1.0"
|
"eslint-visitor-keys": "^1.1.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/experimental-utils": {
|
"@typescript-eslint/experimental-utils": {
|
||||||
"version": "2.22.0",
|
"version": "2.23.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.22.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.23.0.tgz",
|
||||||
"integrity": "sha512-sJt1GYBe6yC0dWOQzXlp+tiuGglNhJC9eXZeC8GBVH98Zv9jtatccuhz0OF5kC/DwChqsNfghHx7OlIDQjNYAQ==",
|
"integrity": "sha512-OswxY59RcXH3NNPmq+4Kis2CYZPurRU6mG5xPcn24CjFyfdVli5mySwZz/g/xDbJXgDsYqNGq7enV0IziWGXVQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/json-schema": "^7.0.3",
|
"@types/json-schema": "^7.0.3",
|
||||||
"@typescript-eslint/typescript-estree": "2.22.0",
|
"@typescript-eslint/typescript-estree": "2.23.0",
|
||||||
"eslint-scope": "^5.0.0"
|
"eslint-scope": "^5.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@typescript-eslint/typescript-estree": {
|
"@typescript-eslint/typescript-estree": {
|
||||||
"version": "2.22.0",
|
"version": "2.23.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.22.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.23.0.tgz",
|
||||||
"integrity": "sha512-2HFZW2FQc4MhIBB8WhDm9lVFaBDy6h9jGrJ4V2Uzxe/ON29HCHBTj3GkgcsgMWfsl2U5as+pTOr30Nibaw7qRQ==",
|
"integrity": "sha512-pmf7IlmvXdlEXvE/JWNNJpEvwBV59wtJqA8MLAxMKLXNKVRC3HZBXR/SlZLPWTCcwOSg9IM7GeRSV3SIerGVqw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
@@ -943,9 +943,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"acorn": {
|
"acorn": {
|
||||||
"version": "7.1.0",
|
"version": "7.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz",
|
||||||
"integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==",
|
"integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"acorn-globals": {
|
"acorn-globals": {
|
||||||
@@ -959,9 +959,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"acorn": {
|
"acorn": {
|
||||||
"version": "6.4.0",
|
"version": "6.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz",
|
||||||
"integrity": "sha512-gac8OEcQ2Li1dxIEWGZzsp2BitJxwkwcOm0zHAJLcPJaVvm58FRnk6RkuLRpU1EujipU2ZFODv2P9DLMfnV8mw==",
|
"integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "actions-github-pages",
|
"name": "actions-github-pages",
|
||||||
"version": "3.5.1",
|
"version": "3.5.3",
|
||||||
"description": "GitHub Actions for GitHub Pages",
|
"description": "GitHub Actions for GitHub Pages",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -59,8 +59,8 @@
|
|||||||
"@types/jest": "^25.1.4",
|
"@types/jest": "^25.1.4",
|
||||||
"@types/js-yaml": "^3.12.2",
|
"@types/js-yaml": "^3.12.2",
|
||||||
"@types/node": "~12",
|
"@types/node": "~12",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.22.0",
|
"@typescript-eslint/eslint-plugin": "^2.23.0",
|
||||||
"@typescript-eslint/parser": "^2.22.0",
|
"@typescript-eslint/parser": "^2.23.0",
|
||||||
"@zeit/ncc": "^0.21.1",
|
"@zeit/ncc": "^0.21.1",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"eslint-plugin-jest": "^23.8.2",
|
"eslint-plugin-jest": "^23.8.2",
|
||||||
|
|||||||
@@ -103,29 +103,34 @@ export async function setRepo(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setConfig(
|
export function getUserName(userName: string): string {
|
||||||
|
if (userName) {
|
||||||
|
return userName;
|
||||||
|
} else {
|
||||||
|
return `${process.env.GITHUB_ACTOR}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getUserEmail(userEmail: string): string {
|
||||||
|
if (userEmail) {
|
||||||
|
return userEmail;
|
||||||
|
} else {
|
||||||
|
return `${process.env.GITHUB_ACTOR}@users.noreply.github.com`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function setCommitAuthor(
|
||||||
userName: string,
|
userName: string,
|
||||||
userEmail: string
|
userEmail: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
await exec.exec('git', ['config', '--global', 'gc.auto', '0']);
|
if (userName && !userEmail) {
|
||||||
|
throw new Error('user_email is undefined');
|
||||||
let name = '';
|
|
||||||
if (userName) {
|
|
||||||
name = userName;
|
|
||||||
} else {
|
|
||||||
name = `${process.env.GITHUB_ACTOR}`;
|
|
||||||
}
|
}
|
||||||
await exec.exec('git', ['config', '--global', 'user.name', name]);
|
if (!userName && userEmail) {
|
||||||
|
throw new Error('user_name is undefined');
|
||||||
let email = '';
|
|
||||||
if (userName !== '' && userEmail !== '') {
|
|
||||||
email = userEmail;
|
|
||||||
} else {
|
|
||||||
email = `${process.env.GITHUB_ACTOR}@users.noreply.github.com`;
|
|
||||||
}
|
}
|
||||||
await exec.exec('git', ['config', '--global', 'user.email', email]);
|
await exec.exec('git', ['config', 'user.name', getUserName(userName)]);
|
||||||
|
await exec.exec('git', ['config', 'user.email', getUserEmail(userEmail)]);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function commit(
|
export async function commit(
|
||||||
|
|||||||
14
src/main.ts
14
src/main.ts
@@ -3,7 +3,7 @@ import * as exec from '@actions/exec';
|
|||||||
import {Inputs} from './interfaces';
|
import {Inputs} from './interfaces';
|
||||||
import {showInputs, getInputs} from './get-inputs';
|
import {showInputs, getInputs} from './get-inputs';
|
||||||
import {setTokens} from './set-tokens';
|
import {setTokens} from './set-tokens';
|
||||||
import * as git from './git-utils';
|
import {setRepo, setCommitAuthor, commit, push, pushTag} from './git-utils';
|
||||||
import {getWorkDirName, addNoJekyll, addCNAME} from './utils';
|
import {getWorkDirName, addNoJekyll, addCNAME} from './utils';
|
||||||
|
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
@@ -11,15 +11,13 @@ export async function run(): Promise<void> {
|
|||||||
const inps: Inputs = getInputs();
|
const inps: Inputs = getInputs();
|
||||||
showInputs(inps);
|
showInputs(inps);
|
||||||
|
|
||||||
await git.setConfig(inps.UserName, inps.UserEmail);
|
|
||||||
|
|
||||||
const remoteURL = await setTokens(inps);
|
const remoteURL = await setTokens(inps);
|
||||||
core.debug(`[INFO] remoteURL: ${remoteURL}`);
|
core.debug(`[INFO] remoteURL: ${remoteURL}`);
|
||||||
|
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const unixTime = date.getTime();
|
const unixTime = date.getTime();
|
||||||
const workDir = await getWorkDirName(`${unixTime}`);
|
const workDir = await getWorkDirName(`${unixTime}`);
|
||||||
await git.setRepo(inps, remoteURL, workDir);
|
await setRepo(inps, remoteURL, workDir);
|
||||||
|
|
||||||
await addNoJekyll(workDir, inps.DisableNoJekyll, inps.PublishBranch);
|
await addNoJekyll(workDir, inps.DisableNoJekyll, inps.PublishBranch);
|
||||||
await addCNAME(workDir, inps.CNAME);
|
await addCNAME(workDir, inps.CNAME);
|
||||||
@@ -31,14 +29,14 @@ export async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
await exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
|
await exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
|
||||||
await exec.exec('git', ['add', '--all']);
|
await exec.exec('git', ['add', '--all']);
|
||||||
|
await setCommitAuthor(inps.UserName, inps.UserEmail);
|
||||||
await git.commit(
|
await commit(
|
||||||
inps.AllowEmptyCommit,
|
inps.AllowEmptyCommit,
|
||||||
inps.ExternalRepository,
|
inps.ExternalRepository,
|
||||||
inps.CommitMessage
|
inps.CommitMessage
|
||||||
);
|
);
|
||||||
await git.push(inps.PublishBranch, inps.ForceOrphan);
|
await push(inps.PublishBranch, inps.ForceOrphan);
|
||||||
await git.pushTag(inps.TagName, inps.TagMessage);
|
await pushTag(inps.TagName, inps.TagMessage);
|
||||||
|
|
||||||
core.info('[INFO] Action successfully completed');
|
core.info('[INFO] Action successfully completed');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user