mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
Merge branch 'dev' into releases/v3
This commit is contained in:
commit
165ce4032c
2
.github/workflows/integration.yml
vendored
2
.github/workflows/integration.yml
vendored
@ -25,7 +25,6 @@ jobs:
|
||||
FOLDER: integration
|
||||
BASE_BRANCH: dev
|
||||
TARGET_FOLDER: cat/montezuma
|
||||
LFS: true
|
||||
GIT_CONFIG_NAME: Montezuma
|
||||
GIT_CONFIG_EMAIL: montezuma@jamesiv.es
|
||||
|
||||
@ -52,7 +51,6 @@ jobs:
|
||||
BRANCH: gh-pages
|
||||
FOLDER: integration
|
||||
BASE_BRANCH: dev
|
||||
LFS: true
|
||||
TARGET_FOLDER: cat/montezuma2
|
||||
|
||||
- name: Cleanup Generated Branch
|
||||
|
@ -151,8 +151,9 @@ In addition to the deployment options you must also configure the following.
|
||||
| `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", "folder"]'` | `with` | **No** |
|
||||
| `SINGLE_COMMIT` | This option can be toggled to `true` if you'd prefer to have a single commit on the deployment branch instead of maintaining the full history. **Using this option will also cause any existing history to be wiped from the deployment branch**. | `with` | **No** |
|
||||
| `LFS` | If toggled all files will be migrated from [Git LFS](https://git-lfs.github.com/) so they can be comitted to the deployment branch. | `with` | **No** |
|
||||
| `PRESERVE` | Preserves and restores the workspace prior to deployment. This option is useful if you're modifying files in the worktree that aren't comitted to Git. | `with` | **No** |
|
||||
| `SILENT` | Silences the action output preventing it from displaying git messages. | `with` | **No** |
|
||||
| `WORKSPACE` | This should point to where your project lives on the virtual machine. The GitHub Actions environment will set this for you. It is only neccersary to set this variable if you're using the node module. | `with` | **No** |
|
||||
| `WORKSPACE` | This should point to where your project lives on the virtual machine. The GitHub Actions environment will set this for you. It is only necessary to set this variable if you're using the node module. | `with` | **No** |
|
||||
|
||||
With the action correctly configured you should see the workflow trigger the deployment under the configured conditions.
|
||||
|
||||
|
@ -241,6 +241,26 @@ describe('git', () => {
|
||||
|
||||
expect(execute).toBeCalledTimes(6)
|
||||
})
|
||||
|
||||
it('should stash changes if preserve is true', async () => {
|
||||
Object.assign(action, {
|
||||
silent: false,
|
||||
repositoryPath: 'JamesIves/github-pages-deploy-action',
|
||||
accessToken: '123',
|
||||
branch: 'branch',
|
||||
folder: '.',
|
||||
preserve: true,
|
||||
isTest: true,
|
||||
pusher: {
|
||||
name: 'asd',
|
||||
email: 'as@cat'
|
||||
}
|
||||
})
|
||||
|
||||
await init(action)
|
||||
|
||||
expect(execute).toBeCalledTimes(7)
|
||||
})
|
||||
})
|
||||
|
||||
describe('generateBranch', () => {
|
||||
@ -364,6 +384,29 @@ describe('git', () => {
|
||||
expect(response).toBe(Status.SUCCESS)
|
||||
})
|
||||
|
||||
it('should execute stash apply commands if preserve is true', async () => {
|
||||
Object.assign(action, {
|
||||
silent: false,
|
||||
folder: 'assets',
|
||||
branch: 'branch',
|
||||
gitHubToken: '123',
|
||||
lfs: true,
|
||||
preserve: true,
|
||||
isTest: true,
|
||||
pusher: {
|
||||
name: 'asd',
|
||||
email: 'as@cat'
|
||||
}
|
||||
})
|
||||
|
||||
const response = await deploy(action)
|
||||
|
||||
// Includes the call to generateBranch
|
||||
expect(execute).toBeCalledTimes(14)
|
||||
expect(rmRF).toBeCalledTimes(1)
|
||||
expect(response).toBe(Status.SUCCESS)
|
||||
})
|
||||
|
||||
it('should not ignore CNAME or nojekyll if they exist in the deployment folder', async () => {
|
||||
Object.assign(action, {
|
||||
silent: false,
|
||||
|
@ -77,6 +77,10 @@ inputs:
|
||||
description: "Silences the action output preventing it from displaying git messages."
|
||||
required: false
|
||||
|
||||
PRESERVE:
|
||||
description: "Preserves and restores any workspace changes prior to deployment."
|
||||
required: false
|
||||
|
||||
outputs:
|
||||
DEPLOYMENT_STATUS:
|
||||
description: 'The status of the deployment that indicates if the run failed or passed. Possible outputs include: success|failed|skipped'
|
||||
|
14
package.json
14
package.json
@ -2,7 +2,7 @@
|
||||
"name": "@jamesives/github-pages-deploy-action",
|
||||
"description": "GitHub action for building a project and deploying it to GitHub pages.",
|
||||
"author": "James Ives <iam@jamesiv.es> (https://jamesiv.es)",
|
||||
"version": "3.6.0",
|
||||
"version": "3.6.1",
|
||||
"license": "MIT",
|
||||
"main": "lib/lib.js",
|
||||
"types": "lib/lib.d.ts",
|
||||
@ -33,21 +33,21 @@
|
||||
"deployment"
|
||||
],
|
||||
"dependencies": {
|
||||
"@actions/core": "1.2.5",
|
||||
"@actions/core": "1.2.6",
|
||||
"@actions/exec": "1.0.4",
|
||||
"@actions/github": "4.0.0",
|
||||
"@actions/io": "1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "26.0.13",
|
||||
"@types/node": "14.10.1",
|
||||
"eslint": "7.8.1",
|
||||
"@types/jest": "26.0.14",
|
||||
"@types/node": "14.11.2",
|
||||
"eslint": "7.9.0",
|
||||
"eslint-plugin-github": "3.4.1",
|
||||
"eslint-plugin-jest": "24.0.0",
|
||||
"eslint-plugin-jest": "24.0.2",
|
||||
"eslint-plugin-prettier": "^3.1.2",
|
||||
"jest": "25.5.4",
|
||||
"jest-circus": "26.4.2",
|
||||
"prettier": "2.1.1",
|
||||
"prettier": "2.1.2",
|
||||
"ts-jest": "25.5.1",
|
||||
"typescript": "3.9.7"
|
||||
}
|
||||
|
@ -32,6 +32,8 @@ export interface ActionInterface {
|
||||
lfs?: boolean | null
|
||||
/** The git config name. */
|
||||
name?: string
|
||||
/** Determines if the workspace should be stashed/restored prior to comitting. */
|
||||
preserve?: boolean | null
|
||||
/** The repository path, for example JamesIves/github-pages-deploy-action. */
|
||||
repositoryName?: string
|
||||
/** The fully qualified repositpory path, this gets auto generated if repositoryName is provided. */
|
||||
@ -85,6 +87,9 @@ export const action: ActionInterface = {
|
||||
: process.env.GITHUB_ACTOR
|
||||
? process.env.GITHUB_ACTOR
|
||||
: 'GitHub Pages Deploy Action',
|
||||
preserve: !isNullOrUndefined(getInput('PRESERVE'))
|
||||
? getInput('PRESERVE').toLowerCase() === 'true'
|
||||
: false,
|
||||
repositoryName: !isNullOrUndefined(getInput('REPOSITORY_NAME'))
|
||||
? getInput('REPOSITORY_NAME')
|
||||
: repository && repository.full_name
|
||||
|
25
src/git.ts
25
src/git.ts
@ -29,12 +29,25 @@ export async function init(action: ActionInterface): Promise<void | Error> {
|
||||
action.silent
|
||||
)
|
||||
|
||||
try {
|
||||
await execute(`git remote rm origin`, action.workspace, action.silent)
|
||||
} finally {
|
||||
if (action.isTest) {
|
||||
info('Attempted to remove origin…')
|
||||
}
|
||||
}
|
||||
|
||||
await execute(
|
||||
`git remote add origin ${action.repositoryPath}`,
|
||||
action.workspace,
|
||||
action.silent
|
||||
)
|
||||
|
||||
if (action.preserve) {
|
||||
info(`Stashing workspace changes… ⬆️`)
|
||||
await execute(`git stash`, action.workspace, action.silent)
|
||||
}
|
||||
|
||||
await execute(
|
||||
`git fetch --no-recurse-submodules`,
|
||||
action.workspace,
|
||||
@ -165,6 +178,18 @@ export async function deploy(action: ActionInterface): Promise<Status> {
|
||||
)
|
||||
}
|
||||
|
||||
if (action.preserve) {
|
||||
info(`Applying stashed workspace changes… ⬆️`)
|
||||
|
||||
try {
|
||||
await execute(`git stash apply`, action.workspace, action.silent)
|
||||
} finally {
|
||||
if (action.isTest) {
|
||||
info('Attempted to apply stash…')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await execute(
|
||||
`git worktree add --checkout ${temporaryDeploymentDirectory} origin/${action.branch}`,
|
||||
action.workspace,
|
||||
|
50
yarn.lock
50
yarn.lock
@ -2,9 +2,9 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@actions/core@1.2.5":
|
||||
version "1.2.5"
|
||||
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.5.tgz#fa57bf8c07a38191e243beb9ea9d8368c1cb02c8"
|
||||
"@actions/core@1.2.6":
|
||||
version "1.2.6"
|
||||
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.2.6.tgz#a78d49f41a4def18e88ce47c2cac615d5694bf09"
|
||||
|
||||
"@actions/exec@1.0.4":
|
||||
version "1.0.4"
|
||||
@ -820,9 +820,9 @@
|
||||
dependencies:
|
||||
"@types/istanbul-lib-report" "*"
|
||||
|
||||
"@types/jest@26.0.13":
|
||||
version "26.0.13"
|
||||
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.13.tgz#5a7b9d5312f5dd521a38329c38ee9d3802a0b85e"
|
||||
"@types/jest@26.0.14":
|
||||
version "26.0.14"
|
||||
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.14.tgz#078695f8f65cb55c5a98450d65083b2b73e5a3f3"
|
||||
dependencies:
|
||||
jest-diff "^25.2.1"
|
||||
pretty-format "^25.2.1"
|
||||
@ -831,9 +831,9 @@
|
||||
version "7.0.4"
|
||||
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.4.tgz#38fd73ddfd9b55abb1e1b2ed578cb55bd7b7d339"
|
||||
|
||||
"@types/node@*", "@types/node@14.10.1", "@types/node@>= 8":
|
||||
version "14.10.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.10.1.tgz#cc323bad8e8a533d4822f45ce4e5326f36e42177"
|
||||
"@types/node@*", "@types/node@14.11.2", "@types/node@>= 8":
|
||||
version "14.11.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.11.2.tgz#2de1ed6670439387da1c9f549a2ade2b0a799256"
|
||||
|
||||
"@types/normalize-package-data@^2.4.0":
|
||||
version "2.4.0"
|
||||
@ -1867,9 +1867,9 @@ eslint-plugin-import@>=2.18.2:
|
||||
read-pkg-up "^2.0.0"
|
||||
resolve "^1.12.0"
|
||||
|
||||
eslint-plugin-jest@24.0.0:
|
||||
version "24.0.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.0.0.tgz#6b1c460c529104c7d16d889e76fe708b281c4d14"
|
||||
eslint-plugin-jest@24.0.2:
|
||||
version "24.0.2"
|
||||
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.0.2.tgz#4bf0fcdc86289d702a7dacb430b4363482af773b"
|
||||
dependencies:
|
||||
"@typescript-eslint/experimental-utils" "^4.0.1"
|
||||
|
||||
@ -1959,9 +1959,9 @@ eslint-visitor-keys@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8"
|
||||
|
||||
eslint@7.8.1:
|
||||
version "7.8.1"
|
||||
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.8.1.tgz#e59de3573fb6a5be8ff526c791571646d124a8fa"
|
||||
eslint@7.9.0:
|
||||
version "7.9.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.9.0.tgz#522aeccc5c3a19017cf0cb46ebfd660a79acf337"
|
||||
dependencies:
|
||||
"@babel/code-frame" "^7.0.0"
|
||||
"@eslint/eslintrc" "^0.1.3"
|
||||
@ -2315,13 +2315,7 @@ getpass@^0.1.1:
|
||||
dependencies:
|
||||
assert-plus "^1.0.0"
|
||||
|
||||
glob-parent@^5.0.0:
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.0.tgz#5f4c1d1e748d30cd73ad2944b3577a81b081e8c2"
|
||||
dependencies:
|
||||
is-glob "^4.0.1"
|
||||
|
||||
glob-parent@^5.1.0:
|
||||
glob-parent@^5.0.0, glob-parent@^5.1.0:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229"
|
||||
dependencies:
|
||||
@ -2500,11 +2494,7 @@ ignore@^4.0.6:
|
||||
version "4.0.6"
|
||||
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
|
||||
|
||||
ignore@^5.0.5:
|
||||
version "5.1.4"
|
||||
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.4.tgz#84b7b3dbe64552b6ef0eca99f6743dbec6d97adf"
|
||||
|
||||
ignore@^5.1.4:
|
||||
ignore@^5.0.5, ignore@^5.1.4:
|
||||
version "5.1.8"
|
||||
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57"
|
||||
|
||||
@ -4145,9 +4135,9 @@ prettier-linter-helpers@^1.0.0:
|
||||
dependencies:
|
||||
fast-diff "^1.1.2"
|
||||
|
||||
prettier@2.1.1, prettier@>=1.12.0:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.1.tgz#d9485dd5e499daa6cb547023b87a6cf51bee37d6"
|
||||
prettier@2.1.2, prettier@>=1.12.0:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5"
|
||||
|
||||
pretty-format@^25.2.1, pretty-format@^25.5.0:
|
||||
version "25.5.0"
|
||||
|
Loading…
Reference in New Issue
Block a user