Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba0b7df03e | ||
|
|
87a781f6ce | ||
|
|
6fa13fefb3 | ||
|
|
efb69e1873 | ||
|
|
9d932c08b7 | ||
|
|
53c9fb0da1 | ||
|
|
d6bd6182f2 | ||
|
|
01fdaf2f02 | ||
|
|
75c03d0413 | ||
|
|
ade70d3851 | ||
|
|
abaaadb545 | ||
|
|
4f06df820b | ||
|
|
ff31e77830 | ||
|
|
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
|
||||||
|
|||||||
122
CHANGELOG.md
122
CHANGELOG.md
@@ -2,6 +2,128 @@
|
|||||||
|
|
||||||
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.6](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.5...v3.5.6) (2020-03-16)
|
||||||
|
|
||||||
|
|
||||||
|
### fix
|
||||||
|
|
||||||
|
* skip on fork (#159) ([6fa13fe](https://github.com/peaceiris/actions-gh-pages/commit/6fa13fefb393227eec5c9710d92e8bffa917546a)), closes [#159](https://github.com/peaceiris/actions-gh-pages/issues/159)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [3.5.5](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.4...v3.5.5) (2020-03-16)
|
||||||
|
|
||||||
|
|
||||||
|
### chore
|
||||||
|
|
||||||
|
* Add new task all ([01fdaf2](https://github.com/peaceiris/actions-gh-pages/commit/01fdaf2f0274401d2403c809b20c37fb7a8535a6))
|
||||||
|
|
||||||
|
### fix
|
||||||
|
|
||||||
|
* skip on fork if pull_request (#158) ([d6bd618](https://github.com/peaceiris/actions-gh-pages/commit/d6bd6182f264ce695613180743d42e377570bbf4)), closes [#158](https://github.com/peaceiris/actions-gh-pages/issues/158) [#157](https://github.com/peaceiris/actions-gh-pages/issues/157)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [3.5.4](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.3...v3.5.4) (2020-03-16)
|
||||||
|
|
||||||
|
|
||||||
|
### fix
|
||||||
|
|
||||||
|
* skip deployment on forks (#156) ([4f06df8](https://github.com/peaceiris/actions-gh-pages/commit/4f06df820b7a5882e2faef0e6929bb670140fba0)), closes [#156](https://github.com/peaceiris/actions-gh-pages/issues/156) [#153](https://github.com/peaceiris/actions-gh-pages/issues/153)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [3.5.4-6](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.4-5...v3.5.4-6) (2020-03-15)
|
||||||
|
|
||||||
|
|
||||||
|
### fix
|
||||||
|
|
||||||
|
* skip logic ([44bdada](https://github.com/peaceiris/actions-gh-pages/commit/44bdada02c71f646d23ffefe1ea07d16386dbf83))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [3.5.4-5](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.4-4...v3.5.4-5) (2020-03-14)
|
||||||
|
|
||||||
|
|
||||||
|
### fix
|
||||||
|
|
||||||
|
* property access ([72f58a0](https://github.com/peaceiris/actions-gh-pages/commit/72f58a06cf5db88d3eb982f57de8dbc266e39232))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [3.5.4-4](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.4-3...v3.5.4-4) (2020-03-14)
|
||||||
|
|
||||||
|
|
||||||
|
### test
|
||||||
|
|
||||||
|
* skipOnFork() ([6f9a5b7](https://github.com/peaceiris/actions-gh-pages/commit/6f9a5b7a66bbf855cadc34099fa6450c40eff4a2))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [3.5.4-3](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.4-2...v3.5.4-3) (2020-03-14)
|
||||||
|
|
||||||
|
|
||||||
|
### fix
|
||||||
|
|
||||||
|
* skip logic ([01976c9](https://github.com/peaceiris/actions-gh-pages/commit/01976c9d9b95b42997caa2a85c2d737eb75e852e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [3.5.4-2](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.4-1...v3.5.4-2) (2020-03-14)
|
||||||
|
|
||||||
|
|
||||||
|
### fix
|
||||||
|
|
||||||
|
* skip logic ([c97a39a](https://github.com/peaceiris/actions-gh-pages/commit/c97a39a35f681badbf7490c2786eddf06b17316d))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [3.5.4-1](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.4-0...v3.5.4-1) (2020-03-14)
|
||||||
|
|
||||||
|
|
||||||
|
### fix
|
||||||
|
|
||||||
|
* isForkRepository ([6546aa9](https://github.com/peaceiris/actions-gh-pages/commit/6546aa96085e89bd91adc56f58be665766e93a1e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [3.5.4-0](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.3...v3.5.4-0) (2020-03-14)
|
||||||
|
|
||||||
|
|
||||||
|
### fix
|
||||||
|
|
||||||
|
* skip on forks ([c320668](https://github.com/peaceiris/actions-gh-pages/commit/c320668126b104ad2c15ea1b583a75cd3978c2f3)), closes [#153](https://github.com/peaceiris/actions-gh-pages/issues/153)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -21,3 +21,7 @@ test:
|
|||||||
.PHONY: commit
|
.PHONY: commit
|
||||||
commit:
|
commit:
|
||||||
$(DOCKER_RUN) git commit -m "$(msg)"
|
$(DOCKER_RUN) git commit -m "$(msg)"
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all:
|
||||||
|
$(DOCKER_RUN) npm run all
|
||||||
|
|||||||
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'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -5,7 +5,8 @@ import {
|
|||||||
getWorkDirName,
|
getWorkDirName,
|
||||||
createWorkDir,
|
createWorkDir,
|
||||||
addNoJekyll,
|
addNoJekyll,
|
||||||
addCNAME
|
addCNAME,
|
||||||
|
skipOnFork
|
||||||
} from '../src/utils';
|
} from '../src/utils';
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -203,3 +204,30 @@ describe('addCNAME()', () => {
|
|||||||
fs.unlinkSync(filepath);
|
fs.unlinkSync(filepath);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('skipOnFork()', () => {
|
||||||
|
test('return false on upstream', async () => {
|
||||||
|
const test = await skipOnFork(false, 'token', '', '');
|
||||||
|
expect(test).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('return false on fork with github_token', async () => {
|
||||||
|
const test = await skipOnFork(true, 'token', '', '');
|
||||||
|
expect(test).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('return false on fork with deploy_key', async () => {
|
||||||
|
const test = await skipOnFork(true, '', 'deploy_key', '');
|
||||||
|
expect(test).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('return false on fork with personal_token', async () => {
|
||||||
|
const test = await skipOnFork(true, '', '', 'personal_token');
|
||||||
|
expect(test).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('return true on fork with no tokens', async () => {
|
||||||
|
const test = await skipOnFork(true, '', '', '');
|
||||||
|
expect(test).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
1457
lib/index.js
1457
lib/index.js
File diff suppressed because it is too large
Load Diff
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.6",
|
||||||
"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.6",
|
||||||
"description": "GitHub Actions for GitHub Pages",
|
"description": "GitHub Actions for GitHub Pages",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
"npm": ">=6.14.2"
|
"npm": ">=6.14.2"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"all": "npm run format && npm run lint && npm test",
|
||||||
"lint": "eslint ./{src,__tests__}/**/*.ts",
|
"lint": "eslint ./{src,__tests__}/**/*.ts",
|
||||||
"lint:fix": "eslint --fix ./{src,__tests__}/**/*.ts",
|
"lint:fix": "eslint --fix ./{src,__tests__}/**/*.ts",
|
||||||
"test": "jest --coverage --verbose --detectOpenHandles",
|
"test": "jest --coverage --verbose --detectOpenHandles",
|
||||||
@@ -59,8 +60,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(
|
||||||
|
|||||||
33
src/main.ts
33
src/main.ts
@@ -1,17 +1,34 @@
|
|||||||
|
import {context} from '@actions/github';
|
||||||
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 {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, skipOnFork} from './utils';
|
||||||
|
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const inps: Inputs = getInputs();
|
const inps: Inputs = getInputs();
|
||||||
showInputs(inps);
|
showInputs(inps);
|
||||||
|
|
||||||
await git.setConfig(inps.UserName, inps.UserEmail);
|
const eventName = context.eventName;
|
||||||
|
if (eventName === 'pull_request' || eventName === 'push') {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
const isForkRepository = (context.payload as any).repository.fork;
|
||||||
|
const isSkipOnFork = await skipOnFork(
|
||||||
|
isForkRepository,
|
||||||
|
inps.GithubToken,
|
||||||
|
inps.DeployKey,
|
||||||
|
inps.PersonalToken
|
||||||
|
);
|
||||||
|
if (isSkipOnFork) {
|
||||||
|
core.warning(
|
||||||
|
'This action runs on a fork and not found auth token, Skip deployment'
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const remoteURL = await setTokens(inps);
|
const remoteURL = await setTokens(inps);
|
||||||
core.debug(`[INFO] remoteURL: ${remoteURL}`);
|
core.debug(`[INFO] remoteURL: ${remoteURL}`);
|
||||||
@@ -19,7 +36,7 @@ export async function run(): Promise<void> {
|
|||||||
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 +48,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');
|
||||||
|
|
||||||
|
|||||||
15
src/utils.ts
15
src/utils.ts
@@ -62,3 +62,18 @@ export async function addCNAME(
|
|||||||
fs.writeFileSync(filepath, content + '\n');
|
fs.writeFileSync(filepath, content + '\n');
|
||||||
core.info(`[INFO] Created ${filepath}`);
|
core.info(`[INFO] Created ${filepath}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function skipOnFork(
|
||||||
|
isForkRepository: boolean,
|
||||||
|
githubToken: string,
|
||||||
|
deployKey: string,
|
||||||
|
personalToken: string
|
||||||
|
): Promise<boolean> {
|
||||||
|
if (isForkRepository) {
|
||||||
|
if (githubToken === '' && deployKey === '' && personalToken === '') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user