From e115e86689d5b4a35d612b2753a97d1e8fe23a58 Mon Sep 17 00:00:00 2001 From: James Ives Date: Wed, 27 Nov 2019 00:27:28 -0500 Subject: [PATCH 1/8] git fetch origin does not work in private repositories --- lib/git.js | 2 +- src/git.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/git.js b/lib/git.js index 81fbe162..bdce914f 100644 --- a/lib/git.js +++ b/lib/git.js @@ -86,7 +86,7 @@ function deploy() { } // Checks out the base branch to begin the deployment process. yield util_1.execute(`git checkout ${constants_1.action.baseBranch || "master"}`, constants_1.workspace); - yield util_1.execute(`git fetch origin`, 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); /* Pushes all of the build files into the deployment directory. diff --git a/src/git.ts b/src/git.ts index 62aaa867..21a4f543 100644 --- a/src/git.ts +++ b/src/git.ts @@ -76,7 +76,7 @@ export async function deploy(): Promise { // Checks out the base branch to begin the deployment process. await execute(`git checkout ${action.baseBranch || "master"}`, workspace); - await execute(`git fetch origin`, workspace); + await execute(`git fetch ${repositoryPath}`, workspace); await execute( `git worktree add --checkout ${temporaryDeploymentDirectory} origin/${action.branch}`, workspace From 799b93b8527af432586ed6b1aca96dc0adaccaf3 Mon Sep 17 00:00:00 2001 From: James Ives Date: Wed, 27 Nov 2019 00:27:34 -0500 Subject: [PATCH 2/8] Revert "git fetch origin does not work in private repositories" This reverts commit e115e86689d5b4a35d612b2753a97d1e8fe23a58. --- lib/git.js | 2 +- src/git.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/git.js b/lib/git.js index bdce914f..81fbe162 100644 --- a/lib/git.js +++ b/lib/git.js @@ -86,7 +86,7 @@ function deploy() { } // Checks out the base branch to begin the deployment process. 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 origin`, constants_1.workspace); 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. diff --git a/src/git.ts b/src/git.ts index 21a4f543..62aaa867 100644 --- a/src/git.ts +++ b/src/git.ts @@ -76,7 +76,7 @@ export async function deploy(): Promise { // Checks out the base branch to begin the deployment process. await execute(`git checkout ${action.baseBranch || "master"}`, workspace); - await execute(`git fetch ${repositoryPath}`, workspace); + await execute(`git fetch origin`, workspace); await execute( `git worktree add --checkout ${temporaryDeploymentDirectory} origin/${action.branch}`, workspace From 5dc80799954fb55564609498d84771d0828a9426 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2019 10:53:16 -0500 Subject: [PATCH 3/8] Bump typescript from 3.7.2 to 3.7.3 (#73) Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.7.2 to 3.7.3. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v3.7.2...v3.7.3) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 0b143380..1ad3b224 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,6 @@ "prettier": "^1.19.1", "ts-jest": "^24.2.0", "tslint": "^5.20.0", - "typescript": "^3.7.2" + "typescript": "^3.7.3" } } diff --git a/yarn.lock b/yarn.lock index 9dd4768f..2891d299 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3133,9 +3133,9 @@ type-check@~0.3.2: dependencies: prelude-ls "~1.1.2" -typescript@^3.7.2: - version "3.7.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.2.tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb" +typescript@^3.7.3: + version "3.7.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.3.tgz#b36840668a16458a7025b9eabfad11b66ab85c69" uglify-js@^3.1.4: version "3.6.8" From db024e903d0ff68dcee00e8dab269e3453251a73 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2019 17:00:30 -0500 Subject: [PATCH 4/8] Bump @types/node from 12.12.14 to 12.12.17 (#81) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 12.12.14 to 12.12.17. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- yarn.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 1ad3b224..c6c56685 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "devDependencies": { "@types/jest": "^24.0.23", - "@types/node": "^12.12.14", + "@types/node": "^12.12.17", "jest": "^24.8.0", "jest-circus": "^24.7.1", "lodash": "^4.17.15", diff --git a/yarn.lock b/yarn.lock index 2891d299..326b8600 100644 --- a/yarn.lock +++ b/yarn.lock @@ -387,9 +387,9 @@ dependencies: jest-diff "^24.3.0" -"@types/node@>= 8", "@types/node@^12.12.14": - version "12.12.14" - resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.14.tgz#1c1d6e3c75dba466e0326948d56e8bd72a1903d2" +"@types/node@>= 8", "@types/node@^12.12.17": + version "12.12.17" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.17.tgz#191b71e7f4c325ee0fb23bc4a996477d92b8c39b" "@types/stack-utils@^1.0.1": version "1.0.1" From 138a7b0f85f6bd6a54141fe88fd9af1749d7bcf4 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sat, 14 Dec 2019 18:14:09 -0500 Subject: [PATCH 5/8] Bump @actions/github from 1.1.0 to 2.0.0 (#79) Bumps [@actions/github](https://github.com/actions/toolkit/tree/HEAD/packages/github) from 1.1.0 to 2.0.0. - [Release notes](https://github.com/actions/toolkit/releases) - [Changelog](https://github.com/actions/toolkit/blob/master/packages/github/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/github) Signed-off-by: dependabot-preview[bot] --- package.json | 2 +- yarn.lock | 29 ++++++++++++----------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index c6c56685..a9115131 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "dependencies": { "@actions/core": "^1.2.0", "@actions/exec": "^1.0.1", - "@actions/github": "^1.1.0" + "@actions/github": "^2.0.0" }, "devDependencies": { "@types/jest": "^24.0.23", diff --git a/yarn.lock b/yarn.lock index 326b8600..76f748e0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10,11 +10,11 @@ version "1.0.1" resolved "https://registry.yarnpkg.com/@actions/exec/-/exec-1.0.1.tgz#1624b541165697e7008d7c87bc1f69f191263c6c" -"@actions/github@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@actions/github/-/github-1.1.0.tgz#06f34e6b0cf07eb2b3641de3e680dbfae6bcd400" +"@actions/github@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@actions/github/-/github-2.0.0.tgz#5b066b1a8747bbf48d47a058d9c241a2e37d5ee7" dependencies: - "@octokit/graphql" "^2.0.1" + "@octokit/graphql" "^4.3.1" "@octokit/rest" "^16.15.0" "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.5.5": @@ -284,12 +284,13 @@ is-plain-object "^3.0.0" universal-user-agent "^4.0.0" -"@octokit/graphql@^2.0.1": - version "2.1.3" - resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-2.1.3.tgz#60c058a0ed5fa242eca6f938908d95fd1a2f4b92" +"@octokit/graphql@^4.3.1": + version "4.3.1" + resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.3.1.tgz#9ee840e04ed2906c7d6763807632de84cdecf418" dependencies: - "@octokit/request" "^5.0.0" - universal-user-agent "^2.0.3" + "@octokit/request" "^5.3.0" + "@octokit/types" "^2.0.0" + universal-user-agent "^4.0.0" "@octokit/request-error@^1.0.1", "@octokit/request-error@^1.0.2": version "1.2.0" @@ -299,7 +300,7 @@ deprecation "^2.0.0" once "^1.4.0" -"@octokit/request@^5.0.0", "@octokit/request@^5.2.0": +"@octokit/request@^5.2.0", "@octokit/request@^5.3.0": version "5.3.1" resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.3.1.tgz#3a1ace45e6f88b1be4749c5da963b3a3b4a2f120" dependencies: @@ -2385,7 +2386,7 @@ os-homedir@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" -os-name@^3.0.0, os-name@^3.1.0: +os-name@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/os-name/-/os-name-3.1.0.tgz#dec19d966296e1cd62d701a5a66ee1ddeae70801" dependencies: @@ -3153,12 +3154,6 @@ union-value@^1.0.0: is-extendable "^0.1.1" set-value "^2.0.1" -universal-user-agent@^2.0.3: - version "2.1.0" - resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-2.1.0.tgz#5abfbcc036a1ba490cb941f8fd68c46d3669e8e4" - dependencies: - os-name "^3.0.0" - universal-user-agent@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-4.0.0.tgz#27da2ec87e32769619f68a14996465ea1cb9df16" From 7674d45914be2bfdb8132af4130aceab0aa29367 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 15 Dec 2019 09:46:44 -0500 Subject: [PATCH 6/8] Bump @actions/exec from 1.0.1 to 1.0.2 (#78) 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] --- package.json | 2 +- yarn.lock | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index a9115131..d2b9a10d 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "license": "MIT", "dependencies": { "@actions/core": "^1.2.0", - "@actions/exec": "^1.0.1", + "@actions/exec": "^1.0.2", "@actions/github": "^2.0.0" }, "devDependencies": { diff --git a/yarn.lock b/yarn.lock index 76f748e0..182df128 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6,9 +6,11 @@ version "1.2.0" resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.0.tgz#aa5f52b26c362c821d41557e599371a42f6c0b3d" -"@actions/exec@^1.0.1": - version "1.0.1" - resolved "https://registry.yarnpkg.com/@actions/exec/-/exec-1.0.1.tgz#1624b541165697e7008d7c87bc1f69f191263c6c" +"@actions/exec@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@actions/exec/-/exec-1.0.2.tgz#80ae9c2ea0bf5d0046a9f73d2a1b15bddfff0311" + dependencies: + "@actions/io" "^1.0.1" "@actions/github@^2.0.0": version "2.0.0" @@ -17,6 +19,10 @@ "@octokit/graphql" "^4.3.1" "@octokit/rest" "^16.15.0" +"@actions/io@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@actions/io/-/io-1.0.1.tgz#81a9418fe2bbdef2d2717a8e9f85188b9c565aca" + "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.5.5": version "7.5.5" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.5.5.tgz#bc0782f6d69f7b7d49531219699b988f669a8f9d" From 0968ee3d9d382753a8a2e5b7b87944d5e756952d Mon Sep 17 00:00:00 2001 From: James Ives Date: Mon, 16 Dec 2019 10:29:19 -0500 Subject: [PATCH 7/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 53d6abab..0f0b44f4 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This [GitHub action](https://github.com/features/actions) will handle the deploy process of your project to [GitHub Pages](https://pages.github.com/). It can be configured to upload your production-ready code into any branch you'd like, including `gh-pages` and `docs`. ## Getting Started :airplane: -You can include the action in your workflow to trigger on any event that [GitHub actions supports](https://help.github.com/en/articles/events-that-trigger-workflows). If the remote branch that you wish to deploy to doesn't already exist the action will create it for you. Your workflow will also need to include the `actions/checkout` step before this workflow runs in order for the deployment to work. +You can include the action in your workflow to trigger on any event that [GitHub actions supports](https://help.github.com/en/articles/events-that-trigger-workflows). If the remote branch that you wish to deploy to doesn't already exist the action will create it for you. Your workflow will also need to include the `actions/checkout@v1` step before this workflow runs in order for the deployment to work. You can view an example of this below. From 771cc5a24a22278008cf49107bd72f9d433614b2 Mon Sep 17 00:00:00 2001 From: James Ives Date: Mon, 16 Dec 2019 10:29:29 -0500 Subject: [PATCH 8/8] [Issue-80] Adds target folder option (#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] * Adds target directory * Target Folder Docs --- README.md | 1 + lib/constants.js | 1 + lib/git.js | 4 +++- src/constants.ts | 1 + src/git.ts | 8 +++++--- 5 files changed, 11 insertions(+), 4 deletions(-) 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}` : ""