mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
Allow Empty Git Email Configs (#926)
* Allow empty email * Update README.md * Update constants.ts * Allow email * unsets email * do not set * Adjusted
This commit is contained in:
parent
1d77ee006d
commit
bd6d73ed7d
@ -137,7 +137,7 @@ By default the action does not need any token configuration and uses the provide
|
|||||||
| Key | Value Information | Type | Required |
|
| Key | Value Information | Type | Required |
|
||||||
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------- |
|
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------- |
|
||||||
| `git-config-name` | Allows you to customize the name that is attached to the git config which is used when pushing the deployment commits. If this is not included it will use the name in the GitHub context, followed by the name of the action. | `with` | **No** |
|
| `git-config-name` | Allows you to customize the name that is attached to the git config which is used when pushing the deployment commits. If this is not included it will use the name in the GitHub context, followed by the name of the action. | `with` | **No** |
|
||||||
| `git-config-email` | Allows you to customize the email that is attached to the git config which is used when pushing the deployment commits. If this is not included it will use the email in the GitHub context, followed by a generic noreply GitHub email. | `with` | **No** |
|
| `git-config-email` | Allows you to customize the email that is attached to the git config which is used when pushing the deployment commits. If this is not included it will use the email in the GitHub context, followed by a generic noreply GitHub email. You can include an empty string value if you wish to omit this field altogether. | `with` | **No** |
|
||||||
| `repository-name` | Allows you to specify a different repository path so long as you have permissions to push to it. This should be formatted like so: `JamesIves/github-pages-deploy-action`. You'll need to use a PAT in the `token` input for this configuration option to work properly. | `with` | **No** |
|
| `repository-name` | Allows you to specify a different repository path so long as you have permissions to push to it. This should be formatted like so: `JamesIves/github-pages-deploy-action`. You'll need to use a PAT in the `token` input for this configuration option to work properly. | `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** |
|
| `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** |
|
||||||
| `commit-message` | If you need to customize the commit message for an integration you can do so. | `with` | **No** |
|
| `commit-message` | If you need to customize the commit message for an integration you can do so. | `with` | **No** |
|
||||||
|
@ -31,6 +31,26 @@ describe('util', () => {
|
|||||||
const value = ''
|
const value = ''
|
||||||
expect(isNullOrUndefined(value)).toBeTruthy()
|
expect(isNullOrUndefined(value)).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should return true if the value is null (with allowEmptyString)', async () => {
|
||||||
|
const value = null
|
||||||
|
expect(isNullOrUndefined(value, true)).toBeTruthy()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return true if the value is undefined (with allowEmptyString)', async () => {
|
||||||
|
const value = undefined
|
||||||
|
expect(isNullOrUndefined(value, true)).toBeTruthy()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return false if the value is defined (with allowEmptyString)', async () => {
|
||||||
|
const value = 'montezuma'
|
||||||
|
expect(isNullOrUndefined(value, true)).toBeFalsy()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should return false if the value is empty string (with allowEmptyString)', async () => {
|
||||||
|
const value = ''
|
||||||
|
expect(isNullOrUndefined(value, true)).toBeFalsy()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('generateTokenType', () => {
|
describe('generateTokenType', () => {
|
||||||
|
@ -95,7 +95,7 @@ export const action: ActionInterface = {
|
|||||||
? stripProtocolFromUrl(process.env.GITHUB_SERVER_URL)
|
? stripProtocolFromUrl(process.env.GITHUB_SERVER_URL)
|
||||||
: 'github.com',
|
: 'github.com',
|
||||||
isTest: TestFlag.NONE,
|
isTest: TestFlag.NONE,
|
||||||
email: !isNullOrUndefined(getInput('git-config-email'))
|
email: !isNullOrUndefined(getInput('git-config-email'), true)
|
||||||
? getInput('git-config-email')
|
? getInput('git-config-email')
|
||||||
: pusher && pusher.email
|
: pusher && pusher.email
|
||||||
? pusher.email
|
? pusher.email
|
||||||
|
@ -22,7 +22,7 @@ export async function init(action: ActionInterface): Promise<void | Error> {
|
|||||||
action.silent
|
action.silent
|
||||||
)
|
)
|
||||||
await execute(
|
await execute(
|
||||||
`git config user.email "${action.email}"`,
|
`git config user.email "${action.email ? action.email : '<>'}"`,
|
||||||
action.workspace,
|
action.workspace,
|
||||||
action.silent
|
action.silent
|
||||||
)
|
)
|
||||||
|
12
src/util.ts
12
src/util.ts
@ -7,9 +7,15 @@ import {ActionInterface, RequiredActionParameters} from './constants'
|
|||||||
const replaceAll = (input: string, find: string, replace: string): string =>
|
const replaceAll = (input: string, find: string, replace: string): string =>
|
||||||
input.split(find).join(replace)
|
input.split(find).join(replace)
|
||||||
|
|
||||||
/* Utility function that checks to see if a value is undefined or not. */
|
/* Utility function that checks to see if a value is undefined or not.
|
||||||
export const isNullOrUndefined = (value: unknown): boolean =>
|
If allowEmptyString is passed the parameter is allowed to contain an empty string as a valid parameter. */
|
||||||
typeof value === 'undefined' || value === null || value === ''
|
export const isNullOrUndefined = (
|
||||||
|
value: unknown,
|
||||||
|
allowEmptyString = false
|
||||||
|
): boolean =>
|
||||||
|
allowEmptyString
|
||||||
|
? typeof value === 'undefined' || value === null
|
||||||
|
: typeof value === 'undefined' || value === null || value === ''
|
||||||
|
|
||||||
/* Generates a token type used for the action. */
|
/* Generates a token type used for the action. */
|
||||||
export const generateTokenType = (action: ActionInterface): string =>
|
export const generateTokenType = (action: ActionInterface): string =>
|
||||||
|
Loading…
Reference in New Issue
Block a user