Skip to content

Commit c0e8d73

Browse files
authoredJun 26, 2022
Set default branch to gh-pages (fix #1151) (#1155)
* Set default branch to gh-pages (fix #1151) * Fix documented requirement of branch
1 parent f7f029d commit c0e8d73

File tree

6 files changed

+18
-28
lines changed

6 files changed

+18
-28
lines changed
 

‎.github/workflows/integration.yml

-12
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ jobs:
3434
git-config-email: montezuma@jamesiv.es
3535
repository-name: MontezumaIves/lab
3636
token: ${{ secrets.ACCESS_TOKEN }}
37-
branch: gh-pages
3837
folder: integration
3938
single-commit: true
4039
clean: true
@@ -52,7 +51,6 @@ jobs:
5251
uses: JamesIves/github-pages-deploy-action@v4.3.3
5352
with:
5453
token: ${{ secrets.ACCESS_TOKEN }}
55-
branch: gh-pages
5654
folder: integration
5755
target-folder: cat/montezuma
5856
git-config-name: Montezuma
@@ -63,7 +61,6 @@ jobs:
6361
uses: dawidd6/action-delete-branch@v3.1.0
6462
with:
6563
github_token: ${{ secrets.GITHUB_TOKEN }}
66-
branches: gh-pages
6764

6865
# Deploys using checkout@v2 with a GITHUB_TOKEN.
6966
integration-checkout-v2:
@@ -78,7 +75,6 @@ jobs:
7875
- name: Build and Deploy
7976
uses: JamesIves/github-pages-deploy-action@v4.3.3
8077
with:
81-
branch: gh-pages
8278
folder: integration
8379
target-folder: cat/montezuma2
8480
silent: true
@@ -87,7 +83,6 @@ jobs:
8783
uses: dawidd6/action-delete-branch@v3.1.0
8884
with:
8985
github_token: ${{ secrets.GITHUB_TOKEN }}
90-
branches: gh-pages
9186

9287
# Deploys using a container that requires you to install rsync.
9388
integration-container:
@@ -110,7 +105,6 @@ jobs:
110105
- name: Build and Deploy
111106
uses: JamesIves/github-pages-deploy-action@v4.3.3
112107
with:
113-
branch: gh-pages
114108
folder: integration
115109
target-folder: cat/montezuma2
116110
silent: true
@@ -135,7 +129,6 @@ jobs:
135129
uses: JamesIves/github-pages-deploy-action@v4.3.3
136130
with:
137131
ssh-key: ${{ secrets.DEPLOY_KEY }}
138-
branch: gh-pages
139132
folder: integration
140133
target-folder: cat/montezuma3
141134
silent: true
@@ -165,7 +158,6 @@ jobs:
165158
uses: JamesIves/github-pages-deploy-action@v4.3.3
166159
with:
167160
ssh-key: true
168-
branch: gh-pages
169161
folder: integration
170162
target-folder: cat/montezuma4
171163
silent: true
@@ -174,7 +166,6 @@ jobs:
174166
uses: dawidd6/action-delete-branch@v3.1.0
175167
with:
176168
github_token: ${{ secrets.GITHUB_TOKEN }}
177-
branches: gh-pages
178169

179170
# Deploys using a custom env. (Includes subsequent commit)
180171
integration-env:
@@ -194,7 +185,6 @@ jobs:
194185
uses: JamesIves/github-pages-deploy-action@v4.3.3
195186
with:
196187
ssh-key: ${{ secrets.DEPLOY_KEY }}
197-
branch: gh-pages
198188
folder: integration
199189
target-folder: cat/montezuma4
200190
silent: true
@@ -203,7 +193,6 @@ jobs:
203193
uses: JamesIves/github-pages-deploy-action@v4.3.3
204194
with:
205195
ssh-key: ${{ secrets.DEPLOY_KEY }}
206-
branch: gh-pages
207196
folder: integration
208197
target-folder: cat/subsequent
209198
silent: true
@@ -236,7 +225,6 @@ jobs:
236225
uses: JamesIves/github-pages-deploy-action@v4.3.3
237226
with:
238227
token: ${{ secrets.ACCESS_TOKEN }}
239-
branch: gh-pages
240228
folder: integration
241229
clean: true
242230
silent: true

‎README.md

+5-11
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ You can view an example of this below.
5959
```yml
6060
name: Build and Deploy
6161
on: [push]
62-
permissions:
62+
permissions:
6363
contents: write
6464
jobs:
6565
build-and-deploy:
@@ -77,7 +77,6 @@ jobs:
7777
- name: Deploy 🚀
7878
uses: JamesIves/github-pages-deploy-action@v4.3.3
7979
with:
80-
branch: gh-pages # The branch the action should deploy to.
8180
folder: build # The folder the action should deploy.
8281
```
8382
@@ -97,7 +96,7 @@ It's recommended that you use [Dependabot](https://docs.github.com/en/code-secur
9796
If you do not supply the action with an access token or an SSH key, you must access your repositories settings and provide `Read and Write Permissions` to the provided `GITHUB_TOKEN`, otherwise you'll potentailly run into permission issues. Alternatively you can set the following in your workflow file to grant the action the permissions it needs.
9897

9998
```yml
100-
permissions:
99+
permissions:
101100
contents: write
102101
```
103102

@@ -126,7 +125,6 @@ import run from '@jamesives/github-pages-deploy-action'
126125

127126
run({
128127
token: process.env['ACCESS_TOKEN'],
129-
branch: 'gh-pages',
130128
folder: 'build',
131129
repositoryName: 'JamesIves/github-pages-deploy-action',
132130
silent: true,
@@ -146,7 +144,6 @@ The following options must be configured in order to make a deployment.
146144

147145
| Key | Value Information | Type | Required |
148146
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------- |
149-
| `branch` | This is the branch you wish to deploy to, for example, `gh-pages` or `docs`. | `with` | **Yes** |
150147
| `folder` | The folder in your repository that you want to deploy. If your build script compiles into a directory named `build` you'd put it here. If you wish to deploy the root directory you can place a `.` here. You can also utilize absolute file paths by appending `~` to your folder path. | `with` | **Yes** |
151148

152149
By default, the action does not need any token configuration and uses the provided repository scoped GitHub token to make the deployment. If you require more customization you can modify the deployment type using the following options.
@@ -160,6 +157,7 @@ By default, the action does not need any token configuration and uses the provid
160157

161158
| Key | Value Information | Type | Required |
162159
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | -------- |
160+
| `branch` | This is the branch you wish to deploy to, for example, `gh-pages` or `docs`. | `with` | **No** |
163161
| `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** |
164162
| `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 `<>` for the value if you wish to omit this field altogether and push the commits without an email. | `with` | **No** |
165163
| `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** |
@@ -205,7 +203,6 @@ With this configured, you can then set the `ssh-key` part of the action to your
205203
- name: Deploy 🚀
206204
uses: JamesIves/github-pages-deploy-action@v4.3.3
207205
with:
208-
branch: gh-pages
209206
folder: site
210207
ssh-key: ${{ secrets.DEPLOY_KEY }}
211208
```
@@ -235,7 +232,6 @@ jobs:
235232
- name: Deploy 🚀
236233
uses: JamesIves/github-pages-deploy-action@v4.3.3
237234
with:
238-
branch: gh-pages
239235
folder: build
240236
clean: true
241237
clean-exclude: |
@@ -269,7 +265,7 @@ If you're using an operating system such as [Windows](https://www.microsoft.com/
269265
```yml
270266
name: Build and Deploy
271267
on: [push]
272-
permissions:
268+
permissions:
273269
contents: write
274270
jobs:
275271
build:
@@ -305,7 +301,6 @@ jobs:
305301
- name: Deploy 🚀
306302
uses: JamesIves/github-pages-deploy-action@v4.3.3
307303
with:
308-
branch: gh-pages
309304
folder: 'site' # The deployment folder should match the name of the artifact. Even though our project builds into the 'build' folder the artifact name of 'site' must be placed here.
310305
```
311306

@@ -338,7 +333,7 @@ If you're using a custom domain and require a `CNAME` file, or if you require th
338333

339334
```yml
340335
name: Build and Deploy
341-
permissions:
336+
permissions:
342337
contents: write
343338
on:
344339
push:
@@ -360,7 +355,6 @@ jobs:
360355
- name: Deploy 🚀
361356
uses: JamesIves/github-pages-deploy-action@v4.3.3
362357
with:
363-
branch: gh-pages
364358
folder: build
365359
clean: true
366360
clean-exclude: |

‎action.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ inputs:
3333

3434
branch:
3535
description: 'This is the branch you wish to deploy to, for example gh-pages or docs.'
36-
required: true
36+
required: false
37+
default: gh-pages
3738

3839
folder:
3940
description: 'The folder in your repository that you want to deploy. If your build script compiles into a directory named build you would put it here. Folder paths cannot have a leading / or ./. If you wish to deploy the root directory you can place a . here.'

‎src/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export interface ActionInterface {
6363
/** The minimum required values to run the action as a node module. */
6464
export interface NodeActionInterface {
6565
/** The branch that the action should deploy to. */
66-
branch: string
66+
branch?: string
6767
/** The folder to deploy. */
6868
folder: string
6969
/** The repository path, for example JamesIves/github-pages-deploy-action. */

‎src/lib.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
extractErrorMessage,
88
generateFolderPath,
99
generateRepositoryPath,
10-
generateTokenType
10+
generateTokenType,
11+
isNullOrUndefined
1112
} from './util'
1213

1314
/** Initializes and runs the action.
@@ -50,7 +51,11 @@ export default async function run(
5051
info('Checking configuration and starting deployment… 🚦')
5152

5253
const settings: ActionInterface = {
53-
...configuration
54+
...configuration,
55+
// Set the default branch for Node configurations
56+
branch: !isNullOrUndefined(configuration.branch)
57+
? configuration.branch
58+
: 'gh-pages'
5459
}
5560

5661
// Defines the repository/folder paths and token types.

‎src/util.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const replaceAll = (input: string, find: string, replace: string): string =>
1414

1515
/* Utility function that checks to see if a value is undefined or not.
1616
If allowEmptyString is passed the parameter is allowed to contain an empty string as a valid parameter. */
17-
export const isNullOrUndefined = (value: unknown): boolean =>
17+
export const isNullOrUndefined = (
18+
value: unknown
19+
): value is undefined | null | '' =>
1820
typeof value === 'undefined' || value === null || value === ''
1921

2022
/* Generates a token type used for the action. */

0 commit comments

Comments
 (0)
Please sign in to comment.