diff --git a/README.md b/README.md index 0f0b44f4..40d1706b 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ Below you'll find a description of what each option does. | `BRANCH` | This is the branch you wish to deploy to, for example `gh-pages` or `docs`. | `with` | **Yes** | | `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** | | `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** | | `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** | With the action correctly configured you should see the workflow trigger the deployment under the configured conditions. diff --git a/lib/constants.js b/lib/constants.js index a08e2b12..34cce3d4 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -23,6 +23,7 @@ exports.action = { gitHubToken: core.getInput("GITHUB_TOKEN"), accessToken: core.getInput("ACCESS_TOKEN"), branch: core.getInput("BRANCH"), + targetFolder: core.getInput("TARGET_FOLDER"), baseBranch: core.getInput("BASE_BRANCH") || "master", name: pusher && pusher.name ? pusher.name diff --git a/lib/git.js b/lib/git.js index bdce914f..bda7eb38 100644 --- a/lib/git.js +++ b/lib/git.js @@ -92,7 +92,9 @@ function deploy() { Pushes all of the build files into the deployment directory. Allows the user to specify the root if '.' is provided. rysync is used to prevent file duplication. */ - 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); + 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.clean ? `--delete --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); if (!hasFilesToCommit && !constants_1.isTest) { console.log("There is nothing to commit. Exiting..."); diff --git a/src/constants.ts b/src/constants.ts index 1d448f06..5a39e3fc 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -18,6 +18,7 @@ export const action = { gitHubToken: core.getInput("GITHUB_TOKEN"), accessToken: core.getInput("ACCESS_TOKEN"), branch: core.getInput("BRANCH"), + targetFolder: core.getInput("TARGET_FOLDER"), baseBranch: core.getInput("BASE_BRANCH") || "master", name: pusher && pusher.name diff --git a/src/git.ts b/src/git.ts index 21a4f543..5ad6c964 100644 --- a/src/git.ts +++ b/src/git.ts @@ -87,9 +87,11 @@ export async function deploy(): Promise { Allows the user to specify the root if '.' is provided. rysync is used to prevent file duplication. */ await execute( - `rsync -q -av --progress ${ - action.build - }/. ${temporaryDeploymentDirectory} ${ + `rsync -q -av --progress ${action.build}/. ${ + action.targetFolder + ? `${temporaryDeploymentDirectory}/${action.targetFolder}` + : temporaryDeploymentDirectory + } ${ action.clean ? `--delete --exclude CNAME --exclude .nojekyll` : "" } --exclude .git --exclude .github ${ action.build === root ? `--exclude ${temporaryDeploymentDirectory}` : ""