Skip to content

Commit 432c473

Browse files
committed
Merge branch 'dev' into releases/v4
2 parents 13046b6 + b3205d4 commit 432c473

12 files changed

+80
-93
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
yarn test
3333
3434
- name: Uploade CodeCov Report
35-
uses: codecov/[email protected].0
35+
uses: codecov/[email protected].1
3636
with:
3737
token: ${{ secrets.CODECOV_TOKEN }}
3838

.github/workflows/integration.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
git-config-email: [email protected]
3535
repository-name: MontezumaIves/lab
3636
token: ${{ secrets.ACCESS_TOKEN }}
37+
commit-message: 'Test commit'
3738
folder: integration
3839
single-commit: true
3940
clean: true

.github/workflows/sponsors.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
file: 'README.md'
1919
template: '<a href="https://github.com/{{{ login }}}"><img src="https://github.com/{{{ login }}}.png" width="50px" alt="{{{ login }}}" /></a>&nbsp;&nbsp;'
2020
maximum: 9999
21-
organization: true
2221

2322
- name: Generate Sponsors 💖
2423
uses: JamesIves/github-sponsors-readme-action@v1
@@ -28,7 +27,6 @@ jobs:
2827
minimum: 10000
2928
template: '<a href="https://github.com/{{{ login }}}"><img src="https://github.com/{{{ login }}}.png" width="80px" alt="{{{ login }}}" /></a>&nbsp;&nbsp;'
3029
marker: 'premium'
31-
organization: true
3230

3331
- name: Deploy to GitHub Pages
3432
uses: JamesIves/github-pages-deploy-action@v4

README.md

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
</p>
4444

4545
<p align="center">
46-
<!-- premium --><a href="https://github.com/github"><img src="https://github.com/github.png" width="80px" alt="github" /></a>&nbsp;&nbsp;<!-- premium -->
46+
<!-- premium --><!-- premium -->
4747
</p>
4848

4949
<p align="center">
@@ -89,52 +89,14 @@ on:
8989
- main
9090
```
9191

92-
It's recommended that you use [Dependabot](https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically) to keep your workflow up-to-date and [secure](https://github.com/features/security). You can find the latest tagged version on the [GitHub Marketplace](https://github.com/marketplace/actions/deploy-to-github-pages) or on the [releases page](https://github.com/JamesIves/github-pages-deploy-action/releases).
93-
94-
#### Permission Settings ⚠️
95-
96-
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.
92+
> **Warning**
93+
> 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 potentially run into permission issues. Alternatively you can set the following in your workflow file to grant the action the permissions it needs.
9794

9895
```yml
9996
permissions:
10097
contents: write
10198
```
10299

103-
#### Install as a Node Module 📦
104-
105-
If you'd like to use the functionality provided by this action in your own action you can either [create a composite action](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action), or you can install it using [yarn](https://yarnpkg.com/) or [npm](https://www.npmjs.com/get-npm) by running the following commands. It's available on both the [npm](https://www.npmjs.com/package/@jamesives/github-pages-deploy-action) and [GitHub registry](https://github.com/JamesIves/github-pages-deploy-action/packages/229985).
106-
107-
```
108-
yarn add @jamesives/github-pages-deploy-action
109-
```
110-
111-
```
112-
npm install @jamesives/github-pages-deploy-action
113-
```
114-
115-
It can then be imported into your project like so.
116-
117-
```javascript
118-
import run from '@jamesives/github-pages-deploy-action'
119-
```
120-
121-
Calling the functions directly will require you to pass in an object containing the variables found in the configuration section, you'll also need to provide a `workspace` with a path to your project.
122-
123-
```javascript
124-
import run from '@jamesives/github-pages-deploy-action'
125-
126-
run({
127-
token: process.env['ACCESS_TOKEN'],
128-
folder: 'build',
129-
repositoryName: 'JamesIves/github-pages-deploy-action',
130-
silent: true,
131-
workspace: 'src/project/location',
132-
tag: 'v0.1'
133-
})
134-
```
135-
136-
For more information regarding the [action interface please click here](https://github.com/JamesIves/github-pages-deploy-action/blob/dev/src/constants.ts#L7).
137-
138100
## Configuration 📁
139101

140102
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).
@@ -170,7 +132,6 @@ By default, the action does not need any token configuration and uses the provid
170132
| `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** |
171133
| `force` | Force-push new deployments to overwrite the previous version; otherwise, attempt to rebase new deployments onto any existing ones. This option is turned on by default and can be toggled off by setting it to `false`, which may be useful if there are multiple deployments in a single branch. | `with` | **No** |
172134
| `silent` | Silences the action output preventing it from displaying git messages. | `with` | **No** |
173-
| `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 necessary to set this variable if you're using the node module. | `with` | **No** |
174135
| `tag` | Add a tag to the commit. Only works when `dry-run` is not used. | `with` | **No** |
175136

176137
With the action correctly configured you should see the workflow trigger the deployment under the configured conditions.

action.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: 'Deploy to GitHub Pages'
22
description: 'This action will handle the deployment process of your project to GitHub Pages.'
33
author: 'James Ives <[email protected]>'
44
runs:
5-
using: 'node12'
5+
using: 'node16'
66
main: 'lib/main.js'
77
branding:
88
icon: 'git-commit'
@@ -24,7 +24,7 @@ inputs:
2424
However if you need more permissions for things such as deploying to another repository, you can add a Personal Access Token (PAT) here.
2525
This should be stored in the `secrets / with` menu **as a secret**.
2626
27-
We recommend using a service account with the least permissions neccersary
27+
We recommend using a service account with the least permissions necessary
2828
and when generating a new PAT that you select the least permission scopes required.
2929
3030
[Learn more about creating and using encrypted secrets here.](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
@@ -58,7 +58,7 @@ inputs:
5858
required: false
5959

6060
dry-run:
61-
description: 'Do not actually push back, but use `--dry-run` on `git push` invocations insead.'
61+
description: 'Do not actually push back, but use `--dry-run` on `git push` invocations instead.'
6262
required: false
6363

6464
force:
@@ -78,10 +78,6 @@ inputs:
7878
description: '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'
7979
required: false
8080

81-
workspace:
82-
description: "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."
83-
required: false
84-
8581
tag:
8682
description: "Add a tag to the commit, this can be used like so: 'v0.1'. Only works when 'dry-run' is not used."
8783
required: false

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@jamesives/github-pages-deploy-action",
33
"description": "GitHub action for building a project and deploying it to GitHub pages.",
44
"author": "James Ives <[email protected]> (https://jamesiv.es)",
5-
"version": "4.3.4",
5+
"version": "4.4.0",
66
"license": "MIT",
77
"main": "lib/lib.js",
88
"types": "lib/lib.d.ts",
@@ -35,25 +35,25 @@
3535
"deployment"
3636
],
3737
"dependencies": {
38-
"@actions/core": "1.9.0",
38+
"@actions/core": "1.10.0",
3939
"@actions/exec": "1.1.1",
40-
"@actions/github": "5.0.3",
40+
"@actions/github": "5.1.1",
4141
"@actions/io": "1.1.2"
4242
},
4343
"devDependencies": {
4444
"@types/jest": "27.5.0",
45-
"@types/node": "18.0.6",
45+
"@types/node": "18.8.0",
4646
"@typescript-eslint/eslint-plugin": "4.33.0",
4747
"@typescript-eslint/parser": "4.33.0",
4848
"eslint": "7.32.0",
4949
"eslint-config-prettier": "8.5.0",
50-
"eslint-plugin-jest": "26.5.3",
50+
"eslint-plugin-jest": "27.0.4",
5151
"eslint-plugin-prettier": "4.2.1",
5252
"jest": "26.6.3",
5353
"jest-circus": "27.5.1",
5454
"prettier": "2.7.1",
5555
"rimraf": "3.0.2",
5656
"ts-jest": "26.5.6",
57-
"typescript": "4.7.4"
57+
"typescript": "4.8.4"
5858
}
5959
}

src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export interface ActionInterface {
4242
name?: string
4343
/** The repository path, for example JamesIves/github-pages-deploy-action. */
4444
repositoryName?: string
45-
/** The fully qualified repositpory path, this gets auto generated if repositoryName is provided. */
45+
/** The fully qualified repository path, this gets auto generated if repositoryName is provided. */
4646
repositoryPath?: string
4747
/** Wipes the commit history from the deployment branch in favor of a single commit. */
4848
singleCommit?: boolean | null

src/git.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import {
1515
suppressSensitiveInformation
1616
} from './util'
1717

18-
/* Initializes git in the workspace. */
18+
/**
19+
* Initializes git in the workspace.
20+
*/
1921
export async function init(action: ActionInterface): Promise<void | Error> {
2022
try {
2123
info(`Deploying using ${action.tokenType}… 🔑`)
@@ -96,7 +98,9 @@ export async function init(action: ActionInterface): Promise<void | Error> {
9698
}
9799
}
98100

99-
/* Runs the necessary steps to make the deployment. */
101+
/**
102+
* Runs the necessary steps to make the deployment.
103+
*/
100104
export async function deploy(action: ActionInterface): Promise<Status> {
101105
const temporaryDeploymentDirectory =
102106
'github-pages-deploy-action-temp-deployment-folder'

src/ssh.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import {appendFileSync} from 'fs'
55
import {ActionInterface} from './constants'
66
import {extractErrorMessage, suppressSensitiveInformation} from './util'
77

8+
/**
9+
* Configures SSH for the workflow.
10+
*/
811
export async function configureSSH(action: ActionInterface): Promise<void> {
912
try {
1013
if (typeof action.sshKey === 'string') {

src/util.ts

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,40 @@ import {
88
SupportedOperatingSystems
99
} from './constants'
1010

11-
/* Replaces all instances of a match in a string. */
11+
/**
12+
* Replaces all instances of a match in a string.
13+
*/
1214
const replaceAll = (input: string, find: string, replace: string): string =>
1315
input.split(find).join(replace)
1416

15-
/* Utility function that checks to see if a value is undefined or not.
16-
If allowEmptyString is passed the parameter is allowed to contain an empty string as a valid parameter. */
17+
/**
18+
* Utility function that checks to see if a value is undefined or not.
19+
* If allowEmptyString is passed the parameter is allowed to contain an empty string as a valid parameter.
20+
*/
1721
export const isNullOrUndefined = (
1822
value: unknown
1923
): value is undefined | null | '' =>
2024
typeof value === 'undefined' || value === null || value === ''
2125

22-
/* Generates a token type used for the action. */
26+
/**
27+
* Generates a token type used for the action.
28+
*/
2329
export const generateTokenType = (action: ActionInterface): string =>
2430
action.sshKey ? 'SSH Deploy Key' : action.token ? 'Deploy Token' : '…'
2531

26-
/* Generates a the repository path used to make the commits. */
32+
/**
33+
* Generates a the repository path used to make the commits.
34+
*/
2735
export const generateRepositoryPath = (action: ActionInterface): string =>
2836
action.sshKey
2937
? `git@${action.hostname}:${action.repositoryName}`
3038
: `https://${`x-access-token:${action.token}`}@${action.hostname}/${
3139
action.repositoryName
3240
}.git`
3341

34-
/* Genetate absolute folder path by the provided folder name */
42+
/**
43+
* Generate absolute folder path by the provided folder name
44+
*/
3545
export const generateFolderPath = (action: ActionInterface): string => {
3646
const folderName = action['folder']
3747
return path.isAbsolute(folderName)
@@ -41,7 +51,9 @@ export const generateFolderPath = (action: ActionInterface): string => {
4151
: path.join(action.workspace, folderName)
4252
}
4353

44-
/* Checks for the required tokens and formatting. Throws an error if any case is matched. */
54+
/**
55+
* Checks for the required tokens and formatting. Throws an error if any case is matched.
56+
*/
4557
const hasRequiredParameters = <K extends keyof RequiredActionParameters>(
4658
action: ActionInterface,
4759
params: K[]
@@ -53,7 +65,9 @@ const hasRequiredParameters = <K extends keyof RequiredActionParameters>(
5365
return Boolean(nonNullParams.length)
5466
}
5567

56-
/* Verifies the action has the required parameters to run, otherwise throw an error. */
68+
/**
69+
* Verifies the action has the required parameters to run, otherwise throw an error.
70+
*/
5771
export const checkParameters = (action: ActionInterface): void => {
5872
if (!hasRequiredParameters(action, ['token', 'sshKey'])) {
5973
throw new Error(
@@ -86,7 +100,9 @@ export const checkParameters = (action: ActionInterface): void => {
86100
}
87101
}
88102

89-
/* Suppresses sensitive information from being exposed in error messages. */
103+
/**
104+
* Suppresses sensitive information from being exposed in error messages.
105+
*/
90106
export const suppressSensitiveInformation = (
91107
str: string,
92108
action: ActionInterface
@@ -109,13 +125,18 @@ export const suppressSensitiveInformation = (
109125
return value
110126
}
111127

128+
/**
129+
* Extracts message from an error object.
130+
*/
112131
export const extractErrorMessage = (error: unknown): string =>
113132
error instanceof Error
114133
? error.message
115134
: typeof error == 'string'
116135
? error
117136
: JSON.stringify(error)
118137

119-
/** Strips the protocol from a provided URL. */
138+
/**
139+
* Strips the protocol from a provided URL.
140+
*/
120141
export const stripProtocolFromUrl = (url: string): string =>
121142
url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, '').split('/')[0]

src/worktree.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export class GitCheckout {
2121
}
2222
}
2323

24-
/* Generate the worktree and set initial content if it exists */
24+
/**
25+
* Generate the worktree and set initial content if it exists
26+
*/
2527
export async function generateWorktree(
2628
action: ActionInterface,
2729
worktreedir: string,

0 commit comments

Comments
 (0)