#373 Adds LFS option

This commit is contained in:
James Ives 2020-09-12 17:33:19 -04:00
parent bad097f84c
commit 9846e33967
5 changed files with 23 additions and 2 deletions

View File

@ -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** |

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

@ -69,6 +69,10 @@ inputs:
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."
required: false

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,6 +148,16 @@ export async function deploy(action: ActionInterface): Promise<Status> {
// 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,