Merge branch 'dev' into releases/v3

This commit is contained in:
James Ives 2020-09-12 18:19:07 -04:00
commit a2ab10e945
9 changed files with 536 additions and 327 deletions

View File

@ -62,11 +62,12 @@ jobs:
npm run build
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@3.5.8
uses: JamesIves/github-pages-deploy-action@3.6.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: build # The folder the action should deploy.
CLEAN: true # Automatically remove deleted files from the deploy branch
```
If you'd like to make it so the workflow only triggers on push events to specific branches then you can modify the `on` section.
@ -146,9 +147,10 @@ In addition to the deployment options you must also configure the following.
| `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** |
| `BASE_BRANCH` | The base branch of your repository which you'd like to checkout prior to deploying. This defaults to the current commit [SHA](http://en.wikipedia.org/wiki/SHA-1) that triggered the build followed by `master` if it doesn't exist. This is useful for making deployments from another branch, and also may be necessary when using a scheduled job. | `with` | **No** |
| `COMMIT_MESSAGE` | If you need to customize the commit message for an integration you can do so. | `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 is turned on by default, and can be toggled off by setting it to `false`. | `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", "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** |
| `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** |

View File

@ -349,6 +349,7 @@ describe('git', () => {
folder: 'assets',
branch: 'branch',
gitHubToken: '123',
lfs: true,
pusher: {
name: 'asd',
email: 'as@cat'
@ -358,7 +359,7 @@ describe('git', () => {
const response = await deploy(action)
// Includes the call to generateBranch
expect(execute).toBeCalledTimes(12)
expect(execute).toBeCalledTimes(13)
expect(rmRF).toBeCalledTimes(1)
expect(response).toBe(Status.SUCCESS)
})

View File

@ -148,9 +148,9 @@ describe('util', () => {
silent: false
}
const string = `This is an error message! It contains ${action.accessToken} and ${action.gitHubToken} and ${action.repositoryPath}`
const string = `This is an error message! It contains ${action.accessToken} and ${action.gitHubToken} and ${action.repositoryPath} and ${action.accessToken} again!`
expect(suppressSensitiveInformation(string, action)).toBe(
'This is an error message! It contains *** and *** and ***'
'This is an error message! It contains *** and *** and *** and *** again!'
)
})

View File

@ -43,6 +43,7 @@ inputs:
CLEAN:
description: '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.'
required: false
default: 'true'
CLEAN_EXCLUDE:
description: "If you need to use CLEAN but you would like to preserve certain files or folders you can use this option. This should be formatted as an array but stored as a string."
@ -67,6 +68,10 @@ inputs:
SINGLE_COMMIT:
description: "This option can be used if you'd prefer to have a single commit on the deployment branch instead of maintaining the full history."
required: false
LFS:
description: "Migrates files from Git LFS so they can be comitted to the deployment branch."
required: false
SILENT:
description: "Silences the action output preventing it from displaying git messages."
@ -74,4 +79,4 @@ inputs:
outputs:
DEPLOYMENT_STATUS:
description: 'The status of the deployment that indicates if the run failed or passed. Possible outputs include: success|failed|skipped'
description: 'The status of the deployment that indicates if the run failed or passed. Possible outputs include: success|failed|skipped'

View File

@ -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.5.8",
"version": "3.5.9",
"license": "MIT",
"main": "lib/lib.js",
"types": "lib/lib.d.ts",
@ -33,21 +33,21 @@
"deployment"
],
"dependencies": {
"@actions/core": "1.2.4",
"@actions/core": "1.2.5",
"@actions/exec": "1.0.4",
"@actions/github": "4.0.0",
"@actions/io": "1.0.2"
},
"devDependencies": {
"@types/jest": "26.0.4",
"@types/node": "14.0.23",
"eslint": "7.4.0",
"@types/jest": "26.0.13",
"@types/node": "14.10.1",
"eslint": "7.8.1",
"eslint-plugin-github": "3.4.1",
"eslint-plugin-jest": "23.18.0",
"eslint-plugin-jest": "24.0.0",
"eslint-plugin-prettier": "^3.1.2",
"jest": "25.5.4",
"jest-circus": "26.1.0",
"prettier": "2.0.5",
"jest-circus": "26.4.2",
"prettier": "2.1.1",
"ts-jest": "25.5.1",
"typescript": "3.9.7"
}

View File

@ -28,6 +28,8 @@ export interface ActionInterface {
gitHubToken?: string | null
/** Determines if the action is running in test mode or not. */
isTest?: boolean | null
/** Removes files from LFS if toggled to allow normal deployment. */
lfs?: boolean | null
/** The git config name. */
name?: string
/** The repository path, for example JamesIves/github-pages-deploy-action. */
@ -65,6 +67,9 @@ export const action: ActionInterface = {
isTest: process.env.UNIT_TEST
? process.env.UNIT_TEST.toLowerCase() === 'true'
: false,
lfs: !isNullOrUndefined(getInput('LFS'))
? getInput('LFS').toLowerCase() === 'true'
: false,
email: !isNullOrUndefined(getInput('GIT_CONFIG_EMAIL'))
? getInput('GIT_CONFIG_EMAIL')
: pusher && pusher.email

View File

@ -148,11 +148,23 @@ export async function deploy(action: ActionInterface): Promise<Status> {
// Checks out the base branch to begin the deployment process.
await switchToBaseBranch(action)
await execute(
`git fetch ${action.repositoryPath}`,
action.workspace,
action.silent
)
if (action.lfs) {
// Migrates data from LFS so it can be comitted the "normal" way.
info(`Migrating from Git LFS… ⚓`)
await execute(
`git lfs migrate export --include="*" --yes`,
action.workspace,
action.silent
)
}
await execute(
`git worktree add --checkout ${temporaryDeploymentDirectory} origin/${action.branch}`,
action.workspace,

View File

@ -1,6 +1,9 @@
import {isDebug} from '@actions/core'
import {ActionInterface} from './constants'
const replaceAll = (input: string, find: string, replace: string): string =>
input.split(find).join(replace)
/* Utility function that checks to see if a value is undefined or not. */
export const isNullOrUndefined = (value: any): boolean =>
typeof value === 'undefined' || value === null || value === ''
@ -64,16 +67,14 @@ export const suppressSensitiveInformation = (
return value
}
if (action.accessToken) {
value = value.replace(action.accessToken, '***')
}
const orderedByLength = ([
action.accessToken,
action.gitHubToken,
action.repositoryPath
].filter(Boolean) as string[]).sort((a, b) => b.length - a.length)
if (action.gitHubToken) {
value = value.replace(action.gitHubToken, '***')
}
if (action.repositoryPath) {
value = value.replace(action.repositoryPath, '***')
for (const find of orderedByLength) {
value = replaceAll(value, find, '***')
}
return value

791
yarn.lock

File diff suppressed because it is too large Load Diff