mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
Debugging
This commit is contained in:
parent
26b25c4e50
commit
a5b924c495
32
lib/git.js
32
lib/git.js
@ -17,6 +17,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const io_1 = require("@actions/io");
|
||||
const util_1 = require("./util");
|
||||
const constants_1 = require("./constants");
|
||||
/** Generates the branch if it doesn't exist on the remote.
|
||||
@ -75,22 +76,31 @@ exports.generateBranch = generateBranch;
|
||||
*/
|
||||
function deploy() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const temporaryDeploymentDirectory = 'gh-action-temp-deployment-folder';
|
||||
const temporaryDeploymentBranch = 'gh-action-temp-deployment-branch';
|
||||
/*
|
||||
Checks to see if the remote exists prior to deploying.
|
||||
If the branch doesn't exist it gets created here as an orphan.
|
||||
|
||||
const branchExists = await execute(
|
||||
`git ls-remote --heads ${repositoryPath} ${action.branch} | wc -l`,
|
||||
workspace
|
||||
);
|
||||
*/
|
||||
const branchExists = yield util_1.execute(`git ls-remote --heads ${constants_1.repositoryPath} ${constants_1.action.branch} | wc -l`, constants_1.workspace);
|
||||
if (!branchExists) {
|
||||
console.log("Deployment branch does not exist. Creating....");
|
||||
//await generateBranch();
|
||||
}*/
|
||||
console.log("Deployment branch does not exist. Creating....");
|
||||
yield generateBranch();
|
||||
}
|
||||
console.log('list', yield util_1.execute(`ls`, constants_1.action.build));
|
||||
yield util_1.execute(`git add .`, constants_1.action.build);
|
||||
yield util_1.execute(`git commit -m "Deploying to ${constants_1.action.branch} from ${constants_1.action.baseBranch} ${process.env.GITHUB_SHA}" --quiet`, constants_1.action.build);
|
||||
yield util_1.execute(`git push --force ${constants_1.repositoryPath} ${constants_1.action.baseBranch}:${constants_1.action.branch}`, constants_1.action.build);
|
||||
yield util_1.execute(`git worktree add --checkout ${temporaryDeploymentDirectory} origin/${constants_1.action.branch}`, constants_1.workspace);
|
||||
/*
|
||||
Pushes all of the build files into the deployment directory.
|
||||
Allows the user to specify the root if '.' is provided. */
|
||||
yield io_1.cp(`${constants_1.action.build}/.`, temporaryDeploymentDirectory, {
|
||||
recursive: true,
|
||||
force: true
|
||||
});
|
||||
// Commits to GitHub.
|
||||
yield util_1.execute(`git add --all .`, 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 push --force ${constants_1.repositoryPath} ${temporaryDeploymentBranch}:${constants_1.action.branch}`, temporaryDeploymentDirectory);
|
||||
return Promise.resolve("Commit step complete...");
|
||||
});
|
||||
}
|
||||
|
36
src/git.ts
36
src/git.ts
@ -60,32 +60,52 @@ export async function generateBranch(): Promise<any> {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
export async function deploy(): Promise<any> {
|
||||
const temporaryDeploymentDirectory = 'gh-action-temp-deployment-folder'
|
||||
const temporaryDeploymentBranch = 'gh-action-temp-deployment-branch'
|
||||
/*
|
||||
Checks to see if the remote exists prior to deploying.
|
||||
If the branch doesn't exist it gets created here as an orphan.
|
||||
|
||||
*/
|
||||
const branchExists = await execute(
|
||||
`git ls-remote --heads ${repositoryPath} ${action.branch} | wc -l`,
|
||||
workspace
|
||||
);
|
||||
if (!branchExists) {
|
||||
console.log("Deployment branch does not exist. Creating....");
|
||||
//await generateBranch();
|
||||
}*/
|
||||
await generateBranch();
|
||||
}
|
||||
|
||||
|
||||
console.log('list', await execute(`ls`, action.build))
|
||||
|
||||
await execute(`git add .`, action.build);
|
||||
await execute(
|
||||
`git commit -m "Deploying to ${action.branch} from ${action.baseBranch} ${process.env.GITHUB_SHA}" --quiet`,
|
||||
action.build
|
||||
`git worktree add --checkout ${temporaryDeploymentDirectory} origin/${action.branch}`,
|
||||
workspace
|
||||
);
|
||||
|
||||
/*
|
||||
Pushes all of the build files into the deployment directory.
|
||||
Allows the user to specify the root if '.' is provided. */
|
||||
await cp(`${action.build}/.`, temporaryDeploymentDirectory, {
|
||||
recursive: true,
|
||||
force: true
|
||||
});
|
||||
|
||||
// Commits to GitHub.
|
||||
await execute(`git add --all .`, temporaryDeploymentDirectory);
|
||||
await execute(
|
||||
`git push --force ${repositoryPath} ${action.baseBranch}:${action.branch}`,
|
||||
action.build
|
||||
`git switch -c ${temporaryDeploymentBranch}`,
|
||||
temporaryDeploymentDirectory
|
||||
);
|
||||
await execute(
|
||||
`git commit -m "Deploying to ${action.branch} from ${action.baseBranch} ${process.env.GITHUB_SHA}" --quiet`,
|
||||
temporaryDeploymentDirectory
|
||||
);
|
||||
await execute(
|
||||
`git push --force ${repositoryPath} ${temporaryDeploymentBranch}:${action.branch}`,
|
||||
temporaryDeploymentDirectory
|
||||
);
|
||||
|
||||
|
||||
return Promise.resolve("Commit step complete...");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user