mirror of
https://github.com/peaceiris/actions-gh-pages.git
synced 2025-07-14 22:29:17 +08:00
feat: Fold logs using core.startGroup() (#277)
cf. https://github.com/actions/toolkit/blob/master/docs/commands.md
This commit is contained in:
parent
504181401b
commit
db3e60d230
17
src/main.ts
17
src/main.ts
@ -18,10 +18,14 @@ 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();
|
||||||
|
core.startGroup('Dump inputs');
|
||||||
showInputs(inps);
|
showInputs(inps);
|
||||||
|
core.endGroup();
|
||||||
|
|
||||||
if (core.isDebug()) {
|
if (core.isDebug()) {
|
||||||
|
core.startGroup('Debug: dump context');
|
||||||
console.log(context);
|
console.log(context);
|
||||||
|
core.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
const eventName = context.eventName;
|
const eventName = context.eventName;
|
||||||
@ -43,17 +47,21 @@ export async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
core.startGroup('Setup auth token');
|
||||||
const remoteURL = await setTokens(inps);
|
const remoteURL = await setTokens(inps);
|
||||||
core.debug(`remoteURL: ${remoteURL}`);
|
core.debug(`remoteURL: ${remoteURL}`);
|
||||||
|
core.endGroup();
|
||||||
|
|
||||||
|
core.startGroup('Prepare publishing assets');
|
||||||
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 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);
|
||||||
|
core.endGroup();
|
||||||
|
|
||||||
|
core.startGroup('Setup Git config');
|
||||||
try {
|
try {
|
||||||
await exec.exec('git', ['remote', 'rm', 'origin']);
|
await exec.exec('git', ['remote', 'rm', 'origin']);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -62,6 +70,9 @@ 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 setCommitAuthor(inps.UserName, inps.UserEmail);
|
||||||
|
core.endGroup();
|
||||||
|
|
||||||
|
core.startGroup('Create a commit');
|
||||||
const hash = `${process.env.GITHUB_SHA}`;
|
const hash = `${process.env.GITHUB_SHA}`;
|
||||||
const baseRepo = `${github.context.repo.owner}/${github.context.repo.repo}`;
|
const baseRepo = `${github.context.repo.owner}/${github.context.repo.repo}`;
|
||||||
const commitMessage = getCommitMessage(
|
const commitMessage = getCommitMessage(
|
||||||
@ -72,8 +83,12 @@ export async function run(): Promise<void> {
|
|||||||
hash
|
hash
|
||||||
);
|
);
|
||||||
await commit(inps.AllowEmptyCommit, commitMessage);
|
await commit(inps.AllowEmptyCommit, commitMessage);
|
||||||
|
core.endGroup();
|
||||||
|
|
||||||
|
core.startGroup('Push the commit or tag');
|
||||||
await push(inps.PublishBranch, inps.ForceOrphan);
|
await push(inps.PublishBranch, inps.ForceOrphan);
|
||||||
await pushTag(inps.TagName, inps.TagMessage);
|
await pushTag(inps.TagName, inps.TagMessage);
|
||||||
|
core.endGroup();
|
||||||
|
|
||||||
core.info('[INFO] Action successfully completed');
|
core.info('[INFO] Action successfully completed');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user