Skip to content

Commit f0e6e50

Browse files
committed
Merge branch 'dev' into releases/v4
2 parents e6d003d + ccec059 commit f0e6e50

File tree

8 files changed

+68
-17
lines changed

8 files changed

+68
-17
lines changed

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Ignore artifacts:
22
build
3-
coverage
3+
coverage
4+
lib

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
</p>
4848

4949
<p align="center">
50-
<!-- sponsors --><a href="https://github.com/Chooksta69"><img src="https://github.com/Chooksta69.png" width="50px" alt="Chooksta69" /></a>&nbsp;&nbsp;<a href="https://github.com/robjtede"><img src="https://github.com/robjtede.png" width="50px" alt="robjtede" /></a>&nbsp;&nbsp;<a href="https://github.com/hadley"><img src="https://github.com/hadley.png" width="50px" alt="hadley" /></a>&nbsp;&nbsp;<a href="https://github.com/kevinchalet"><img src="https://github.com/kevinchalet.png" width="50px" alt="kevinchalet" /></a>&nbsp;&nbsp;<a href="https://github.com/Yousazoe"><img src="https://github.com/Yousazoe.png" width="50px" alt="Yousazoe" /></a>&nbsp;&nbsp;<!-- sponsors -->
50+
<!-- sponsors --><a href="https://github.com/Chooksta69"><img src="https://github.com/Chooksta69.png" width="50px" alt="Chooksta69" /></a>&nbsp;&nbsp;<a href="https://github.com/robjtede"><img src="https://github.com/robjtede.png" width="50px" alt="robjtede" /></a>&nbsp;&nbsp;<a href="https://github.com/hadley"><img src="https://github.com/hadley.png" width="50px" alt="hadley" /></a>&nbsp;&nbsp;<a href="https://github.com/kevinchalet"><img src="https://github.com/kevinchalet.png" width="50px" alt="kevinchalet" /></a>&nbsp;&nbsp;<!-- sponsors -->
5151
</p>
5252

5353
## Getting Started :airplane:
@@ -128,7 +128,8 @@ run({
128128
folder: 'build',
129129
repositoryName: 'JamesIves/github-pages-deploy-action',
130130
silent: true,
131-
workspace: 'src/project/location'
131+
workspace: 'src/project/location',
132+
tag: 'v0.1'
132133
})
133134
```
134135

@@ -170,6 +171,7 @@ By default, the action does not need any token configuration and uses the provid
170171
| `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** |
171172
| `silent` | Silences the action output preventing it from displaying git messages. | `with` | **No** |
172173
| `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** |
174+
| `tag` | Add a tag to the commit. Only works when `dry-run` is not used. | `with` | **No** |
173175

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

__tests__/git.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,5 +449,26 @@ describe('git', () => {
449449
)
450450
}
451451
})
452+
453+
it('should add a tag to the commit', async () => {
454+
Object.assign(action, {
455+
hostname: 'github.com',
456+
silent: false,
457+
folder: 'assets',
458+
branch: 'branch',
459+
token: '123',
460+
repositoryName: 'JamesIves/montezuma',
461+
tag: 'v0.1',
462+
pusher: {
463+
name: 'asd',
464+
email: 'as@cat'
465+
},
466+
isTest: TestFlag.HAS_CHANGED_FILES
467+
})
468+
469+
const response = await deploy(action)
470+
expect(execute).toBeCalledTimes(16)
471+
expect(response).toBe(Status.SUCCESS)
472+
})
452473
})
453474
})

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ inputs:
8282
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."
8383
required: false
8484

85+
tag:
86+
description: "Add a tag to the commit, this can be used like so: 'v0.1'. Only works when 'dry-run' is not used."
87+
required: false
88+
8589
single-commit:
8690
description: "This option can be used if you'd prefer to have a single commit on the deployment branch instead of maintaining the full history."
8791
required: false

package.json

Lines changed: 3 additions & 3 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.3",
5+
"version": "4.3.4",
66
"license": "MIT",
77
"main": "lib/lib.js",
88
"types": "lib/lib.d.ts",
@@ -42,13 +42,13 @@
4242
},
4343
"devDependencies": {
4444
"@types/jest": "27.5.0",
45-
"@types/node": "18.0.0",
45+
"@types/node": "18.0.6",
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",
5050
"eslint-plugin-jest": "26.5.3",
51-
"eslint-plugin-prettier": "4.0.0",
51+
"eslint-plugin-prettier": "4.2.1",
5252
"jest": "26.6.3",
5353
"jest-circus": "27.5.1",
5454
"prettier": "2.7.1",

src/constants.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ export interface ActionInterface {
5858
tokenType?: string
5959
/** The folder where your deployment project lives. */
6060
workspace: string
61+
/** GitHub tag name */
62+
tag?: string | null
6163
}
6264

6365
/** The minimum required values to run the action as a node module. */
@@ -138,7 +140,8 @@ export const action: ActionInterface = {
138140
? true
139141
: getInput('ssh-key'),
140142
targetFolder: getInput('target-folder'),
141-
workspace: process.env.GITHUB_WORKSPACE || ''
143+
workspace: process.env.GITHUB_WORKSPACE || '',
144+
tag: getInput('tag')
142145
}
143146

144147
/** Types for the required action parameters. */

src/git.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,34 @@ export async function deploy(action: ActionInterface): Promise<Status> {
308308

309309
if (rejected) info('Updates were rejected')
310310

311-
// If the push failed for any reason other than being rejected,
311+
// If the push failed for any fatal reason other than being rejected,
312312
// there is a problem
313-
if (!rejected && pushResult.stderr) throw new Error(pushResult.stderr)
313+
if (!rejected && pushResult.stderr.trim().startsWith('fatal:'))
314+
throw new Error(pushResult.stderr)
314315
} while (rejected)
315316
}
316317

317318
info(`Changes committed to the ${action.branch} branch… 📦`)
318319

320+
if (action.tag) {
321+
info(`Adding '${action.tag}' tag to the commit…`)
322+
await execute(
323+
`git tag ${action.tag}`,
324+
`${action.workspace}/${temporaryDeploymentDirectory}`,
325+
action.silent
326+
)
327+
info(`Pushing '${action.tag}' tag to repository…`)
328+
await execute(
329+
`git push origin ${action.tag}`,
330+
`${action.workspace}/${temporaryDeploymentDirectory}`,
331+
action.silent
332+
)
333+
334+
info(
335+
`Tag '${action.tag}' created and pushed to the ${action.branch} branch… 🏷️`
336+
)
337+
}
338+
319339
return Status.SUCCESS
320340
} catch (error) {
321341
throw new Error(

yarn.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,10 +1276,10 @@
12761276
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d"
12771277
integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==
12781278

1279-
"@types/node@*", "@types/[email protected].0", "@types/node@>= 8":
1280-
version "18.0.0"
1281-
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.0.0.tgz#67c7b724e1bcdd7a8821ce0d5ee184d3b4dd525a"
1282-
integrity sha512-cHlGmko4gWLVI27cGJntjs/Sj8th9aYwplmZFwmmgYQQvL5NUsgVJG7OddLvNfLqYS31KFN0s3qlaD9qCaxACA==
1279+
"@types/node@*", "@types/[email protected].6", "@types/node@>= 8":
1280+
version "18.0.6"
1281+
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.0.6.tgz#0ba49ac517ad69abe7a1508bc9b3a5483df9d5d7"
1282+
integrity sha512-/xUq6H2aQm261exT6iZTMifUySEt4GR5KX8eYyY+C4MSNPqSh9oNIP7tz2GLKTlFaiBbgZNxffoR3CVRG+cljw==
12831283

12841284
"@types/normalize-package-data@^2.4.0":
12851285
version "2.4.0"
@@ -2152,10 +2152,10 @@ [email protected]:
21522152
dependencies:
21532153
"@typescript-eslint/utils" "^5.10.0"
21542154

2155-
eslint-plugin-prettier@4.0.0:
2156-
version "4.0.0"
2157-
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz#8b99d1e4b8b24a762472b4567992023619cb98e0"
2158-
integrity sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==
2155+
eslint-plugin-prettier@4.2.1:
2156+
version "4.2.1"
2157+
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz#651cbb88b1dab98bfd42f017a12fa6b2d993f94b"
2158+
integrity sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==
21592159
dependencies:
21602160
prettier-linter-helpers "^1.0.0"
21612161

0 commit comments

Comments
 (0)