MCPcopy Index your code
hub / github.com/JamesIves/github-pages-deploy-action / deploy

Function deploy

lib/git.js:78–229  ·  view source on GitHub ↗

* Runs the necessary steps to make the deployment.

(action)

Source from the content-addressed store, hash-verified

76 * Runs the necessary steps to make the deployment.
77 */
78function deploy(action) {
79 return __awaiter(this, void 0, void 0, function* () {
80 const temporaryDeploymentDirectory = 'github-pages-deploy-action-temp-deployment-folder';
81 const temporaryDeploymentBranch = `github-pages-deploy-action/${Math.random()
82 .toString(36)
83 .substr(2, 9)}`;
84 const rsyncVersion = (0, util_1.getRsyncVersion)();
85 const isMkpathSupported = rsyncVersion >= '3.2.3';
86 (0, core_1.info)('Starting to commit changes…');
87 try {
88 const commitMessage = !(0, util_1.isNullOrUndefined)(action.commitMessage)
89 ? action.commitMessage
90 : `Deploying to ${action.branch}${process.env.GITHUB_SHA
91 ? ` from @ ${process.env.GITHUB_REPOSITORY}@${process.env.GITHUB_SHA}`
92 : ''} 🚀`;
93 // Checks to see if the remote exists prior to deploying.
94 const branchExists = action.isTest & constants_1.TestFlag.HAS_REMOTE_BRANCH ||
95 Boolean((yield (0, execute_1.execute)(`git ls-remote --heads ${action.repositoryPath} refs/heads/${action.branch}`, action.workspace, action.silent)).stdout);
96 yield (0, worktree_1.generateWorktree)(action, temporaryDeploymentDirectory, branchExists);
97 /* Relaxes permissions of folder due to be deployed so rsync can write to/from it. */
98 try {
99 yield (0, execute_1.execute)(`chmod -R +rw ${action.folderPath}`, action.workspace, true // Always silent to avoid flooding output on read-only folders
100 );
101 }
102 catch (_a) {
103 // Silently ignore chmod failures - they are non-critical and often occur with read-only folders
104 }
105 // Ensures that items that need to be excluded from the clean job get parsed.
106 let excludes = '';
107 if (action.clean && action.cleanExclude) {
108 for (const item of action.cleanExclude) {
109 excludes += `--exclude ${item} `;
110 }
111 }
112 if (action.targetFolder) {
113 (0, core_1.info)(`Creating target folder if it doesn't already exist… 📌`);
114 yield (0, io_1.mkdirP)(`${temporaryDeploymentDirectory}/${action.targetFolder}`);
115 }
116 /*
117 Pushes all of the build files into the deployment directory.
118 Allows the user to specify the root if '.' is provided.
119 rsync is used to prevent file duplication. */
120 yield (0, execute_1.execute)(`rsync -q -av --checksum --progress ${isMkpathSupported && action.targetFolder ? '--mkpath' : ''} ${action.folderPath}/. ${action.targetFolder
121 ? `${temporaryDeploymentDirectory}/${action.targetFolder}`
122 : temporaryDeploymentDirectory} ${action.clean
123 ? `--delete ${excludes} ${!fs_1.default.existsSync(`${action.folderPath}/${constants_1.DefaultExcludedFiles.CNAME}`)
124 ? `--exclude ${constants_1.DefaultExcludedFiles.CNAME}`
125 : ''} ${!fs_1.default.existsSync(`${action.folderPath}/${constants_1.DefaultExcludedFiles.NOJEKYLL}`)
126 ? `--exclude ${constants_1.DefaultExcludedFiles.NOJEKYLL}`
127 : ''}`
128 : ''} --exclude ${constants_1.DefaultExcludedFiles.SSH} --exclude ${constants_1.DefaultExcludedFiles.GIT} --exclude ${constants_1.DefaultExcludedFiles.GITHUB} ${action.folderPath === action.workspace
129 ? `--exclude ${temporaryDeploymentDirectory}`
130 : ''}`, action.workspace, action.silent);
131 if (action.singleCommit) {
132 yield (0, execute_1.execute)(`git add --all .`, `${action.workspace}/${temporaryDeploymentDirectory}`, action.silent);
133 }
134 // Use git status to check if we have something to commit.
135 // Special case is singleCommit with existing history, when

Callers 1

git.test.tsFile · 0.90

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected