8000 [Issue-80] Adds target folder option (#82) · cauu/github-pages-deploy-action@771cc5a · GitHub
[go: up one dir, main page]

Skip to content

Commit 771cc5a

Browse files
authored
[Issue-80] Adds target folder option (JamesIves#82)
* Bump @actions/exec from 1.0.1 to 1.0.2 Bumps [@actions/exec](https://github.com/actions/toolkit/tree/HEAD/packages/exec) from 1.0.1 to 1.0.2. - [Release notes](https://github.com/actions/toolkit/releases) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/exec) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Adds target directory * Target Folder Docs
1 parent 0968ee3 commit 771cc5a

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Below you'll find a description of what each option does.
108108
| `BRANCH` | This is the branch you wish to deploy to, for example `gh-pages` or `docs`. | `with` | **Yes** |
109109
| `FOLDER` | The folder in your repository that you want to deploy. If your build script compiles into a directory named `build` you'd put it here. **Folder paths cannot have a leading `/` or `./`**. If you wish to deploy the root directory you can place a `.` here. | `with` | **Yes** |
110110
| `BASE_BRANCH` | The base branch of your repository which you'd like to checkout prior to deploying. This defaults to `master`. | `with` | **No** |
111+
| `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** |
111112
| `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** |
112113

113114
With the action correctly configured you should see the workflow trigger the deployment under the configured conditions.

lib/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ exports.action = {
2323
gitHubToken: core.getInput("GITHUB_TOKEN"),
2424
accessToken: core.getInput("ACCESS_TOKEN"),
2525
branch: core.getInput("BRANCH"),
26+
targetFolder: core.getInput("TARGET_FOLDER"),
2627
baseBranch: core.getInput("BASE_BRANCH") || "master",
2728
name: pusher && pusher.name
2829
? pusher.name

lib/git.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ function deploy() {
9292
Pushes all of the build files into the deployment directory.
9393
Allows the user to specify the root if '.' is provided.
9494
rysync is used to prevent file duplication. */
95-
yield util_1.execute(`rsync -q -av --progress ${constants_1.action.build}/. ${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);
95+
yield util_1.execute(`rsync -q -av --progress ${constants_1.action.build}/. ${constants_1.action.targetFolder
96+
? `${temporaryDeploymentDirectory}/${constants_1.action.targetFolder}`
97+
: 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);
9698
const hasFilesToCommit = yield util_1.execute(`git status --porcelain`, temporaryDeploymentDirectory);
9799
if (!hasFilesToCommit && !constants_1.isTest) {
98100
console.log("There is nothing to commit. Exiting...");

src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const action = {
1818
gitHubToken: core.getInput("GITHUB_TOKEN"),
1919
accessToken: core.getInput("ACCESS_TOKEN"),
2020
branch: core.getInput("BRANCH"),
21+
targetFolder: core.getInput("TARGET_FOLDER"),
2122
baseBranch: core.getInput("BASE_BRANCH") || "master",
2223
name:
2324
pusher && pusher.name

src/git.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ export async function deploy(): Promise<any> {
8787
Allows the user to specify the root if '.' is provided.
8888
rysync is used to prevent file duplication. */
8989
await execute(
90-
`rsync -q -av --progress ${
91-
action.build
92-
}/. ${temporaryDeploymentDirectory} ${
90+
`rsync -q -av --progress ${action.build}/. ${
91+
action.targetFolder
92+
? `${temporaryDeploymentDirectory}/${action.targetFolder}`
93+
: temporaryDeploymentDirectory
94+
} ${
9395
action.clean ? `--delete --exclude CNAME --exclude .nojekyll` : ""
9496
} --exclude .git --exclude .github ${
9597
action.build === root ? `--exclude ${temporaryDeploymentDirectory}` : ""

0 commit comments

Comments
 (0)
0