mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
commit
7cdf918284
@ -110,6 +110,7 @@ Below you'll find a description of what each option does.
|
|||||||
| `BASE_BRANCH` | The base branch of your repository which you'd like to checkout prior to deploying. This defaults to `master`. | `with` | **No** |
|
| `BASE_BRANCH` | The base branch of your repository which you'd like to checkout prior to deploying. This defaults to `master`. | `with` | **No** |
|
||||||
| `TARGET_FOLDER` | If you'd like to push the contents of the deployment folder into a specific directory on the deployment branch you can specify it here. | `with` | **No** |
|
| `TARGET_FOLDER` | If you'd like to push the contents of the deployment folder into a specific directory on the deployment branch you can specify it here. | `with` | **No** |
|
||||||
| `CLEAN` | If your project generates hashed files on build you can use this option to automatically delete them from the deployment branch with each deploy. This option can be toggled on by setting it to `true`. | `with` | **No** |
|
| `CLEAN` | If your project generates hashed files on build you can use this option to automatically delete them from the deployment branch with each deploy. This option can be toggled on by setting it to `true`. | `with` | **No** |
|
||||||
|
| `CLEAN_EXCLUDE` | If you need to use `CLEAN` but you'd like to preserve certain files or folders you can use this option. This should be formatted as an array but stored as a string. For example: `'["filename.js", "./folderpath"]'` | `with` | **No** |
|
||||||
|
|
||||||
With the action correctly configured you should see the workflow trigger the deployment under the configured conditions.
|
With the action correctly configured you should see the workflow trigger the deployment under the configured conditions.
|
||||||
|
|
||||||
|
@ -34,7 +34,8 @@ exports.action = {
|
|||||||
? pusher.email
|
? pusher.email
|
||||||
: `${process.env.GITHUB_ACTOR ||
|
: `${process.env.GITHUB_ACTOR ||
|
||||||
"github-pages-deploy-action"}@users.noreply.github.com`,
|
"github-pages-deploy-action"}@users.noreply.github.com`,
|
||||||
clean: core.getInput("CLEAN")
|
clean: core.getInput("CLEAN"),
|
||||||
|
cleanExclude: core.getInput("CLEAN_EXCLUDE")
|
||||||
};
|
};
|
||||||
// Repository path used for commits/pushes.
|
// Repository path used for commits/pushes.
|
||||||
exports.repositoryPath = `https://${exports.action.accessToken ||
|
exports.repositoryPath = `https://${exports.action.accessToken ||
|
||||||
|
15
lib/git.js
15
lib/git.js
@ -88,13 +88,26 @@ function deploy() {
|
|||||||
yield util_1.execute(`git checkout ${constants_1.action.baseBranch || "master"}`, constants_1.workspace);
|
yield util_1.execute(`git checkout ${constants_1.action.baseBranch || "master"}`, constants_1.workspace);
|
||||||
yield util_1.execute(`git fetch ${constants_1.repositoryPath}`, constants_1.workspace);
|
yield util_1.execute(`git fetch ${constants_1.repositoryPath}`, 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);
|
||||||
|
// Ensures that items that need to be excluded from the clean job get parsed.
|
||||||
|
let excludes = "";
|
||||||
|
if (constants_1.action.clean && constants_1.action.cleanExclude) {
|
||||||
|
try {
|
||||||
|
const excludedItems = JSON.parse(constants_1.action.cleanExclude);
|
||||||
|
excludedItems.forEach((item) => (excludes += `--exclude ${item} `));
|
||||||
|
}
|
||||||
|
catch (_a) {
|
||||||
|
console.log("There was an error parsing your CLEAN_EXCLUDE items. Please refer to the README for more details.");
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
Pushes all of the build files into the deployment directory.
|
Pushes all of the build files into the deployment directory.
|
||||||
Allows the user to specify the root if '.' is provided.
|
Allows the user to specify the root if '.' is provided.
|
||||||
rysync is used to prevent file duplication. */
|
rysync is used to prevent file duplication. */
|
||||||
yield util_1.execute(`rsync -q -av --progress ${constants_1.action.build}/. ${constants_1.action.targetFolder
|
yield util_1.execute(`rsync -q -av --progress ${constants_1.action.build}/. ${constants_1.action.targetFolder
|
||||||
? `${temporaryDeploymentDirectory}/${constants_1.action.targetFolder}`
|
? `${temporaryDeploymentDirectory}/${constants_1.action.targetFolder}`
|
||||||
: temporaryDeploymentDirectory} ${constants_1.action.clean ? `--delete --exclude CNAME --exclude .nojekyll` : ""} --exclude .git --exclude .github ${constants_1.action.build === constants_1.root ? `--exclude ${temporaryDeploymentDirectory}` : ""}`, constants_1.workspace);
|
: temporaryDeploymentDirectory} ${constants_1.action.clean
|
||||||
|
? `--delete ${excludes} --exclude CNAME --exclude .nojekyll`
|
||||||
|
: ""} --exclude .git --exclude .github ${constants_1.action.build === constants_1.root ? `--exclude ${temporaryDeploymentDirectory}` : ""}`, constants_1.workspace);
|
||||||
const hasFilesToCommit = yield util_1.execute(`git status --porcelain`, temporaryDeploymentDirectory);
|
const hasFilesToCommit = yield util_1.execute(`git status --porcelain`, temporaryDeploymentDirectory);
|
||||||
if (!hasFilesToCommit && !constants_1.isTest) {
|
if (!hasFilesToCommit && !constants_1.isTest) {
|
||||||
console.log("There is nothing to commit. Exiting...");
|
console.log("There is nothing to commit. Exiting...");
|
||||||
|
@ -31,7 +31,8 @@ export const action = {
|
|||||||
? pusher.email
|
? pusher.email
|
||||||
: `${process.env.GITHUB_ACTOR ||
|
: `${process.env.GITHUB_ACTOR ||
|
||||||
"github-pages-deploy-action"}@users.noreply.github.com`,
|
"github-pages-deploy-action"}@users.noreply.github.com`,
|
||||||
clean: core.getInput("CLEAN")
|
clean: core.getInput("CLEAN"),
|
||||||
|
cleanExclude: core.getInput("CLEAN_EXCLUDE")
|
||||||
};
|
};
|
||||||
|
|
||||||
// Repository path used for commits/pushes.
|
// Repository path used for commits/pushes.
|
||||||
|
19
src/git.ts
19
src/git.ts
@ -82,6 +82,21 @@ export async function deploy(): Promise<any> {
|
|||||||
workspace
|
workspace
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Ensures that items that need to be excluded from the clean job get parsed.
|
||||||
|
let excludes = "";
|
||||||
|
if (action.clean && action.cleanExclude) {
|
||||||
|
try {
|
||||||
|
const excludedItems = JSON.parse(action.cleanExclude);
|
||||||
|
excludedItems.forEach(
|
||||||
|
(item: string) => (excludes += `--exclude ${item} `)
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
console.log(
|
||||||
|
"There was an error parsing your CLEAN_EXCLUDE items. Please refer to the README for more details."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Pushes all of the build files into the deployment directory.
|
Pushes all of the build files into the deployment directory.
|
||||||
Allows the user to specify the root if '.' is provided.
|
Allows the user to specify the root if '.' is provided.
|
||||||
@ -92,7 +107,9 @@ export async function deploy(): Promise<any> {
|
|||||||
? `${temporaryDeploymentDirectory}/${action.targetFolder}`
|
? `${temporaryDeploymentDirectory}/${action.targetFolder}`
|
||||||
: temporaryDeploymentDirectory
|
: temporaryDeploymentDirectory
|
||||||
} ${
|
} ${
|
||||||
action.clean ? `--delete --exclude CNAME --exclude .nojekyll` : ""
|
action.clean
|
||||||
|
? `--delete ${excludes} --exclude CNAME --exclude .nojekyll`
|
||||||
|
: ""
|
||||||
} --exclude .git --exclude .github ${
|
} --exclude .git --exclude .github ${
|
||||||
action.build === root ? `--exclude ${temporaryDeploymentDirectory}` : ""
|
action.build === root ? `--exclude ${temporaryDeploymentDirectory}` : ""
|
||||||
}`,
|
}`,
|
||||||
|
Loading…
Reference in New Issue
Block a user