Skip to content

Commit 2ec414d

Browse files
committed
Fixes error handling and details in the readme.
1 parent 35d2f57 commit 2ec414d

File tree

6 files changed

+33
-13
lines changed

6 files changed

+33
-13
lines changed

.github/ISSUE_TEMPLATE/BUG_REPORT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ labels:
1313
<!-- Steps to reproduce the behavior. -->
1414

1515
**Logs**
16-
<!-- Please provide your deployment logs and a link or sample to/of your workflow. -->
16+
<!-- 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. -->
1717

1818
**Additional Comments**
1919
<!--Add any other context about the problem here. -->

.github/ISSUE_TEMPLATE/SUPPORT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ labels:
1010
<!-- Please provide a clear and concise description of what the problem is. Please be sure to read the README first! -->
1111

1212
**Logs**
13-
<!-- Please provide your deployment logs and a link or sample to/of your workflow. -->
13+
<!-- 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. -->
1414

1515
**Additional Comments**
1616
<!-- Add any other context about the issue here. -->

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,17 @@ For more information regarding the [action interface please click here](https://
115115

116116
## Configuration 📁
117117

118-
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).
118+
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).
119119

120120
#### Required Setup
121121

122122
One of the following deployment options must be configured.
123123

124124
| Key | Value Information | Type | Required |
125-
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | -------- |
125+
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---- | ---------------- | -------- |
126+
| `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** |
126127
| `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** |
127-
| `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** |
128-
| `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** |
128+
| `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** |
129129

130130
In addition to the deployment options you must also configure the following.
131131

@@ -161,7 +161,7 @@ If you'd prefer to use an SSH deploy key as opposed to a token you must first ge
161161
ssh-keygen -t rsa -b 4096 -C "youremailhere@example.com" -N ""
162162
```
163163

164-
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`.
164+
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`.
165165

166166
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.
167167

__tests__/git.test.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,28 @@ describe('git', () => {
8989
name: 'asd',
9090
email: 'as@cat'
9191
},
92-
gitHubToken: null,
93-
accessToken: null,
94-
ssh: null
92+
})
93+
94+
try {
95+
await init(action)
96+
} catch (e) {
97+
expect(execute).toBeCalledTimes(0)
98+
expect(e.message).toMatch(
99+
'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. ❌'
100+
)
101+
}
102+
})
103+
104+
it('should fail if access token is defined but it is an empty string', async () => {
105+
Object.assign(action, {
106+
repositoryPath: null,
107+
folder: 'build',
108+
branch: 'branch',
109+
pusher: {
110+
name: 'asd',
111+
email: 'as@cat'
112+
},
113+
accessToken: '',
95114
})
96115

97116
try {

__tests__/util.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe('util', () => {
7373
accessToken: null,
7474
ssh: null
7575
}
76-
expect(generateTokenType(action)).toEqual('...')
76+
expect(generateTokenType(action)).toEqual('')
7777
})
7878
})
7979

src/util.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const generateTokenType = (action: ActionInterface): string =>
1313
? 'Access Token'
1414
: action.gitHubToken
1515
? 'GitHub Token'
16-
: '...'
16+
: ''
1717

1818
/* Generates a the repository path used to make the commits. */
1919
export const generateRepositoryPath = (action: ActionInterface): string =>
@@ -29,7 +29,8 @@ export const hasRequiredParameters = (action: ActionInterface): void => {
2929
(isNullOrUndefined(action.accessToken) &&
3030
isNullOrUndefined(action.gitHubToken) &&
3131
isNullOrUndefined(action.ssh)) ||
32-
isNullOrUndefined(action.repositoryPath)
32+
isNullOrUndefined(action.repositoryPath) ||
33+
(action.accessToken && action.accessToken === '')
3334
) {
3435
throw new Error(
3536
'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.'

0 commit comments

Comments
 (0)