mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
Using Git Switch as opposed to checkout
This commit is contained in:
parent
8a6a3ab51b
commit
7ec4ff590a
@ -52,8 +52,8 @@ function generateBranch() {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
console.log(`Creating ${constants_1.action.branch} branch...`);
|
console.log(`Creating ${constants_1.action.branch} branch...`);
|
||||||
yield util_1.execute(`git checkout ${constants_1.action.baseBranch || "master"} ---`, constants_1.workspace);
|
yield util_1.execute(`git switch ${constants_1.action.baseBranch || "master"}`, constants_1.workspace);
|
||||||
yield util_1.execute(`git checkout --orphan ${constants_1.action.branch} ---`, constants_1.workspace);
|
yield util_1.execute(`git switch --orphan ${constants_1.action.branch}`, constants_1.workspace);
|
||||||
yield util_1.execute(`git reset --hard`, constants_1.workspace);
|
yield util_1.execute(`git reset --hard`, constants_1.workspace);
|
||||||
yield util_1.execute(`git commit --allow-empty -m "Initial ${constants_1.action.branch} commit."`, constants_1.workspace);
|
yield util_1.execute(`git commit --allow-empty -m "Initial ${constants_1.action.branch} commit."`, constants_1.workspace);
|
||||||
yield util_1.execute(`git push ${constants_1.repositoryPath} ${constants_1.action.branch}`, constants_1.workspace);
|
yield util_1.execute(`git push ${constants_1.repositoryPath} ${constants_1.action.branch}`, constants_1.workspace);
|
||||||
@ -84,7 +84,7 @@ function deploy() {
|
|||||||
yield generateBranch();
|
yield generateBranch();
|
||||||
}
|
}
|
||||||
// Checks out the base branch to begin the deployment process.
|
// Checks out the base branch to begin the deployment process.
|
||||||
yield util_1.execute(`git checkout ${constants_1.action.baseBranch || "master"} ---`, constants_1.workspace);
|
yield util_1.execute(`git switch ${constants_1.action.baseBranch || "master"}`, constants_1.workspace);
|
||||||
yield util_1.execute(`git fetch origin`, constants_1.workspace);
|
yield util_1.execute(`git fetch origin`, constants_1.workspace);
|
||||||
yield util_1.execute(`git worktree add --checkout ${temporaryDeploymentDirectory} origin/${constants_1.action.branch}`, constants_1.workspace);
|
yield util_1.execute(`git worktree add --checkout ${temporaryDeploymentDirectory} origin/${constants_1.action.branch}`, constants_1.workspace);
|
||||||
/*
|
/*
|
||||||
@ -96,7 +96,7 @@ function deploy() {
|
|||||||
});
|
});
|
||||||
// Commits to GitHub.
|
// Commits to GitHub.
|
||||||
yield util_1.execute(`git add --all .`, temporaryDeploymentDirectory);
|
yield util_1.execute(`git add --all .`, temporaryDeploymentDirectory);
|
||||||
yield util_1.execute(`git checkout -b ${temporaryDeploymentBranch} ---`, temporaryDeploymentDirectory);
|
yield util_1.execute(`git switch -c ${temporaryDeploymentBranch}`, temporaryDeploymentDirectory);
|
||||||
yield util_1.execute(`git commit -m "Deploying to ${constants_1.action.branch} from ${constants_1.action.baseBranch} ${process.env.GITHUB_SHA}" --quiet`, temporaryDeploymentDirectory);
|
yield util_1.execute(`git commit -m "Deploying to ${constants_1.action.branch} from ${constants_1.action.baseBranch} ${process.env.GITHUB_SHA}" --quiet`, temporaryDeploymentDirectory);
|
||||||
yield util_1.execute(`git push ${constants_1.repositoryPath} ${temporaryDeploymentBranch}:${constants_1.action.branch}`, temporaryDeploymentDirectory);
|
yield util_1.execute(`git push ${constants_1.repositoryPath} ${temporaryDeploymentBranch}:${constants_1.action.branch}`, temporaryDeploymentDirectory);
|
||||||
return Promise.resolve("Commit step complete...");
|
return Promise.resolve("Commit step complete...");
|
||||||
|
@ -36,8 +36,8 @@ export async function init(): Promise<any> {
|
|||||||
export async function generateBranch(): Promise<any> {
|
export async function generateBranch(): Promise<any> {
|
||||||
try {
|
try {
|
||||||
console.log(`Creating ${action.branch} branch...`);
|
console.log(`Creating ${action.branch} branch...`);
|
||||||
await execute(`git checkout ${action.baseBranch || "master"} ---`, workspace);
|
await execute(`git switch ${action.baseBranch || "master"}`, workspace);
|
||||||
await execute(`git checkout --orphan ${action.branch} ---`, workspace);
|
await execute(`git switch --orphan ${action.branch}`, workspace);
|
||||||
await execute(`git reset --hard`, workspace);
|
await execute(`git reset --hard`, workspace);
|
||||||
await execute(
|
await execute(
|
||||||
`git commit --allow-empty -m "Initial ${action.branch} commit."`,
|
`git commit --allow-empty -m "Initial ${action.branch} commit."`,
|
||||||
@ -74,7 +74,7 @@ export async function deploy(): Promise<any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checks out the base branch to begin the deployment process.
|
// Checks out the base branch to begin the deployment process.
|
||||||
await execute(`git checkout ${action.baseBranch || "master"} ---`, workspace);
|
await execute(`git switch ${action.baseBranch || "master"}`, workspace);
|
||||||
await execute(`git fetch origin`, workspace);
|
await execute(`git fetch origin`, workspace);
|
||||||
await execute(
|
await execute(
|
||||||
`git worktree add --checkout ${temporaryDeploymentDirectory} origin/${action.branch}`,
|
`git worktree add --checkout ${temporaryDeploymentDirectory} origin/${action.branch}`,
|
||||||
@ -92,7 +92,7 @@ export async function deploy(): Promise<any> {
|
|||||||
// Commits to GitHub.
|
// Commits to GitHub.
|
||||||
await execute(`git add --all .`, temporaryDeploymentDirectory);
|
await execute(`git add --all .`, temporaryDeploymentDirectory);
|
||||||
await execute(
|
await execute(
|
||||||
`git checkout -b ${temporaryDeploymentBranch} ---`,
|
`git switch -c ${temporaryDeploymentBranch}`,
|
||||||
temporaryDeploymentDirectory
|
temporaryDeploymentDirectory
|
||||||
);
|
);
|
||||||
await execute(
|
await execute(
|
||||||
|
Loading…
Reference in New Issue
Block a user