diff --git a/README.md b/README.md index 550f2b14..5a6baacc 100644 --- a/README.md +++ b/README.md @@ -147,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** | diff --git a/__tests__/git.test.ts b/__tests__/git.test.ts index 0f7ed7c8..f0eec7e2 100644 --- a/__tests__/git.test.ts +++ b/__tests__/git.test.ts @@ -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) }) diff --git a/action.yml b/action.yml index 72c53384..80675603 100644 --- a/action.yml +++ b/action.yml @@ -68,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 + + SINGLE_COMMIT: + 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." diff --git a/src/constants.ts b/src/constants.ts index cdf6a5c7..2ee97de5 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -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 diff --git a/src/git.ts b/src/git.ts index 55ef8b97..7f745ad0 100644 --- a/src/git.ts +++ b/src/git.ts @@ -148,6 +148,16 @@ export async function deploy(action: ActionInterface): Promise { // Checks out the base branch to begin the deployment process. await switchToBaseBranch(action) + + if (action.lfs) { + // Migrates data from LFS so it can be comitted the "normal" way. + await execute( + `git lfs migrate export --include="*"`, + action.workspace, + action.silent + ) + } + await execute( `git fetch ${action.repositoryPath}`, action.workspace,