mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
Fixes error handling and details in the readme.
This commit is contained in:
parent
35d2f578e5
commit
2ec414d8d6
2
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
2
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
@ -13,7 +13,7 @@ labels:
|
|||||||
<!-- Steps to reproduce the behavior. -->
|
<!-- Steps to reproduce the behavior. -->
|
||||||
|
|
||||||
**Logs**
|
**Logs**
|
||||||
<!-- Please provide your deployment logs and a link or sample to/of your workflow. -->
|
<!-- Please provide your deployment logs and a link or sample to/of your workflow. If the error message isn't revealing the problem please set ACTIONS_STEP_DEBUG to true in your repository's secrets menu and run the workflow again. -->
|
||||||
|
|
||||||
**Additional Comments**
|
**Additional Comments**
|
||||||
<!--Add any other context about the problem here. -->
|
<!--Add any other context about the problem here. -->
|
||||||
|
2
.github/ISSUE_TEMPLATE/SUPPORT.md
vendored
2
.github/ISSUE_TEMPLATE/SUPPORT.md
vendored
@ -10,7 +10,7 @@ labels:
|
|||||||
<!-- Please provide a clear and concise description of what the problem is. Please be sure to read the README first! -->
|
<!-- Please provide a clear and concise description of what the problem is. Please be sure to read the README first! -->
|
||||||
|
|
||||||
**Logs**
|
**Logs**
|
||||||
<!-- Please provide your deployment logs and a link or sample to/of your workflow. -->
|
<!-- Please provide your deployment logs and a link or sample to/of your workflow. If the error message isn't revealing the problem please set ACTIONS_STEP_DEBUG to true in your repository's secrets menu and run the workflow again. -->
|
||||||
|
|
||||||
**Additional Comments**
|
**Additional Comments**
|
||||||
<!-- Add any other context about the issue here. -->
|
<!-- Add any other context about the issue here. -->
|
||||||
|
10
README.md
10
README.md
@ -115,17 +115,17 @@ For more information regarding the [action interface please click here](https://
|
|||||||
|
|
||||||
## Configuration 📁
|
## Configuration 📁
|
||||||
|
|
||||||
The `with` portion of the workflow **must** be configured before the action will work. You can add these in the `with` section found in the examples above. Any `secrets` must be referenced using the bracket syntax and stored in the GitHub repositories `Settings/Secrets` menu. You can learn more about setting environment variables with GitHub actions [here](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#creating-encrypted-secrets).
|
The `with` portion of the workflow **must** be configured before the action will work. You can add these in the `with` section found in the examples above. Any `secrets` must be referenced using the bracket syntax and stored in the GitHub repository's `Settings/Secrets` menu. You can learn more about setting environment variables with GitHub actions [here](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#creating-encrypted-secrets).
|
||||||
|
|
||||||
#### Required Setup
|
#### Required Setup
|
||||||
|
|
||||||
One of the following deployment options must be configured.
|
One of the following deployment options must be configured.
|
||||||
|
|
||||||
| Key | Value Information | Type | Required |
|
| Key | Value Information | Type | Required |
|
||||||
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | -------- |
|
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---- | ---------------- | -------- |
|
||||||
|
| `GITHUB_TOKEN` | In order for GitHub to trigger the rebuild of your page you must provide the action with the repository's provided GitHub token. This can be referenced in the workflow `yml` file by using `${{ secrets.GITHUB_TOKEN }}`. If you experience any issues with your changes not being reflected after the deployment it may be neccersary to use either the `SSH` or `ACCESS_TOKEN` options. | `secrets / with` | **Yes** |
|
||||||
| `SSH` | You can configure the action to deploy using SSH by setting this option to `true`. For more information on how to add your ssh key pair please refer to the [Using a Deploy Key section of this README](https://github.com/JamesIves/github-pages-deploy-action/tree/dev#using-an-ssh-deploy-key-). | `with` | **Yes** |
|
| `SSH` | You can configure the action to deploy using SSH by setting this option to `true`. For more information on how to add your ssh key pair please refer to the [Using a Deploy Key section of this README](https://github.com/JamesIves/github-pages-deploy-action/tree/dev#using-an-ssh-deploy-key-). | `with` | **Yes** |
|
||||||
| `ACCESS_TOKEN` | Depending on the repository permissions you may need to provide the action with a GitHub personal access token instead of the provided GitHub token in order to deploy. You can [learn more about how to generate one here](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line). **This should be stored as a secret**. | `secrets / with` | **Yes** |
|
| `ACCESS_TOKEN` | Depending on the repository's permissions you may need to provide the action with a GitHub personal access token instead of the provided GitHub token in order to deploy. You can [learn more about how to generate one here](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line). **This should be stored as a secret**. | `secrets / with` | **Yes** |
|
||||||
| `GITHUB_TOKEN` | In order for GitHub to trigger the rebuild of your page you must provide the action with the repositories provided GitHub token. This can be referenced in the workflow `yml` file by using `${{ secrets.GITHUB_TOKEN }}`. **Please note there is currently an issue affecting the use of this token which makes it so it only works with private repositories, [you can learn more here](https://github.com/JamesIves/github-pages-deploy-action/issues/5)**. | `secrets / with` | **Yes** |
|
|
||||||
|
|
||||||
In addition to the deployment options you must also configure the following.
|
In addition to the deployment options you must also configure the following.
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ If you'd prefer to use an SSH deploy key as opposed to a token you must first ge
|
|||||||
ssh-keygen -t rsa -b 4096 -C "youremailhere@example.com" -N ""
|
ssh-keygen -t rsa -b 4096 -C "youremailhere@example.com" -N ""
|
||||||
```
|
```
|
||||||
|
|
||||||
Once you've generated the key pair you must add the contents of the public key within your repositories [deploy keys menu](https://developer.github.com/v3/guides/managing-deploy-keys/). You can find this option by going to `Settings > Deploy Keys`, you can name the public key whatever you want, but you **do** need to give it write access. Afterwards add the contents of the private key to the `Settings > Secrets` menu as `DEPLOY_KEY`.
|
Once you've generated the key pair you must add the contents of the public key within your repository's [deploy keys menu](https://developer.github.com/v3/guides/managing-deploy-keys/). You can find this option by going to `Settings > Deploy Keys`, you can name the public key whatever you want, but you **do** need to give it write access. Afterwards add the contents of the private key to the `Settings > Secrets` menu as `DEPLOY_KEY`.
|
||||||
|
|
||||||
With this configured you must add the `ssh-agent` step to your workflow and set `SSH` to `true` within the deploy action. There are several SSH actions available on the [GitHub marketplace](https://github.com/marketplace?type=actions) for you to choose from.
|
With this configured you must add the `ssh-agent` step to your workflow and set `SSH` to `true` within the deploy action. There are several SSH actions available on the [GitHub marketplace](https://github.com/marketplace?type=actions) for you to choose from.
|
||||||
|
|
||||||
|
@ -89,9 +89,28 @@ describe('git', () => {
|
|||||||
name: 'asd',
|
name: 'asd',
|
||||||
email: 'as@cat'
|
email: 'as@cat'
|
||||||
},
|
},
|
||||||
gitHubToken: null,
|
})
|
||||||
accessToken: null,
|
|
||||||
ssh: null
|
try {
|
||||||
|
await init(action)
|
||||||
|
} catch (e) {
|
||||||
|
expect(execute).toBeCalledTimes(0)
|
||||||
|
expect(e.message).toMatch(
|
||||||
|
'There was an error initializing the repository: No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true. ❌'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should fail if access token is defined but it is an empty string', async () => {
|
||||||
|
Object.assign(action, {
|
||||||
|
repositoryPath: null,
|
||||||
|
folder: 'build',
|
||||||
|
branch: 'branch',
|
||||||
|
pusher: {
|
||||||
|
name: 'asd',
|
||||||
|
email: 'as@cat'
|
||||||
|
},
|
||||||
|
accessToken: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -73,7 +73,7 @@ describe('util', () => {
|
|||||||
accessToken: null,
|
accessToken: null,
|
||||||
ssh: null
|
ssh: null
|
||||||
}
|
}
|
||||||
expect(generateTokenType(action)).toEqual('...')
|
expect(generateTokenType(action)).toEqual('…')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ export const generateTokenType = (action: ActionInterface): string =>
|
|||||||
? 'Access Token'
|
? 'Access Token'
|
||||||
: action.gitHubToken
|
: action.gitHubToken
|
||||||
? 'GitHub Token'
|
? 'GitHub Token'
|
||||||
: '...'
|
: '…'
|
||||||
|
|
||||||
/* Generates a the repository path used to make the commits. */
|
/* Generates a the repository path used to make the commits. */
|
||||||
export const generateRepositoryPath = (action: ActionInterface): string =>
|
export const generateRepositoryPath = (action: ActionInterface): string =>
|
||||||
@ -29,7 +29,8 @@ export const hasRequiredParameters = (action: ActionInterface): void => {
|
|||||||
(isNullOrUndefined(action.accessToken) &&
|
(isNullOrUndefined(action.accessToken) &&
|
||||||
isNullOrUndefined(action.gitHubToken) &&
|
isNullOrUndefined(action.gitHubToken) &&
|
||||||
isNullOrUndefined(action.ssh)) ||
|
isNullOrUndefined(action.ssh)) ||
|
||||||
isNullOrUndefined(action.repositoryPath)
|
isNullOrUndefined(action.repositoryPath) ||
|
||||||
|
(action.accessToken && action.accessToken === '')
|
||||||
) {
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.'
|
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.'
|
||||||
|
Loading…
Reference in New Issue
Block a user