Merge branch 'dev' into releases/v4

This commit is contained in:
James Ives 2022-07-20 11:03:10 -04:00
commit f0e6e506b4
8 changed files with 68 additions and 17 deletions

View File

@ -1,3 +1,4 @@
# Ignore artifacts: # Ignore artifacts:
build build
coverage coverage
lib

View File

@ -47,7 +47,7 @@
</p> </p>
<p align="center"> <p align="center">
<!-- 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 --> <!-- 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 -->
</p> </p>
## Getting Started :airplane: ## Getting Started :airplane:
@ -128,7 +128,8 @@ run({
folder: 'build', folder: 'build',
repositoryName: 'JamesIves/github-pages-deploy-action', repositoryName: 'JamesIves/github-pages-deploy-action',
silent: true, silent: true,
workspace: 'src/project/location' workspace: 'src/project/location',
tag: 'v0.1'
}) })
``` ```
@ -170,6 +171,7 @@ By default, the action does not need any token configuration and uses the provid
| `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** | | `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** |
| `silent` | Silences the action output preventing it from displaying git messages. | `with` | **No** | | `silent` | Silences the action output preventing it from displaying git messages. | `with` | **No** |
| `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** | | `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** |
| `tag` | Add a tag to the commit. Only works when `dry-run` is not used. | `with` | **No** |
With the action correctly configured you should see the workflow trigger the deployment under the configured conditions. With the action correctly configured you should see the workflow trigger the deployment under the configured conditions.

View File

@ -449,5 +449,26 @@ describe('git', () => {
) )
} }
}) })
it('should add a tag to the commit', async () => {
Object.assign(action, {
hostname: 'github.com',
silent: false,
folder: 'assets',
branch: 'branch',
token: '123',
repositoryName: 'JamesIves/montezuma',
tag: 'v0.1',
pusher: {
name: 'asd',
email: 'as@cat'
},
isTest: TestFlag.HAS_CHANGED_FILES
})
const response = await deploy(action)
expect(execute).toBeCalledTimes(16)
expect(response).toBe(Status.SUCCESS)
})
}) })
}) })

View File

@ -82,6 +82,10 @@ inputs:
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." 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."
required: false required: false
tag:
description: "Add a tag to the commit, this can be used like so: 'v0.1'. Only works when 'dry-run' is not used."
required: false
single-commit: single-commit:
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." 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."
required: false required: false

View File

@ -2,7 +2,7 @@
"name": "@jamesives/github-pages-deploy-action", "name": "@jamesives/github-pages-deploy-action",
"description": "GitHub action for building a project and deploying it to GitHub pages.", "description": "GitHub action for building a project and deploying it to GitHub pages.",
"author": "James Ives <iam@jamesiv.es> (https://jamesiv.es)", "author": "James Ives <iam@jamesiv.es> (https://jamesiv.es)",
"version": "4.3.3", "version": "4.3.4",
"license": "MIT", "license": "MIT",
"main": "lib/lib.js", "main": "lib/lib.js",
"types": "lib/lib.d.ts", "types": "lib/lib.d.ts",
@ -42,13 +42,13 @@
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "27.5.0", "@types/jest": "27.5.0",
"@types/node": "18.0.0", "@types/node": "18.0.6",
"@typescript-eslint/eslint-plugin": "4.33.0", "@typescript-eslint/eslint-plugin": "4.33.0",
"@typescript-eslint/parser": "4.33.0", "@typescript-eslint/parser": "4.33.0",
"eslint": "7.32.0", "eslint": "7.32.0",
"eslint-config-prettier": "8.5.0", "eslint-config-prettier": "8.5.0",
"eslint-plugin-jest": "26.5.3", "eslint-plugin-jest": "26.5.3",
"eslint-plugin-prettier": "4.0.0", "eslint-plugin-prettier": "4.2.1",
"jest": "26.6.3", "jest": "26.6.3",
"jest-circus": "27.5.1", "jest-circus": "27.5.1",
"prettier": "2.7.1", "prettier": "2.7.1",

View File

@ -58,6 +58,8 @@ export interface ActionInterface {
tokenType?: string tokenType?: string
/** The folder where your deployment project lives. */ /** The folder where your deployment project lives. */
workspace: string workspace: string
/** GitHub tag name */
tag?: string | null
} }
/** The minimum required values to run the action as a node module. */ /** The minimum required values to run the action as a node module. */
@ -138,7 +140,8 @@ export const action: ActionInterface = {
? true ? true
: getInput('ssh-key'), : getInput('ssh-key'),
targetFolder: getInput('target-folder'), targetFolder: getInput('target-folder'),
workspace: process.env.GITHUB_WORKSPACE || '' workspace: process.env.GITHUB_WORKSPACE || '',
tag: getInput('tag')
} }
/** Types for the required action parameters. */ /** Types for the required action parameters. */

View File

@ -308,14 +308,34 @@ export async function deploy(action: ActionInterface): Promise<Status> {
if (rejected) info('Updates were rejected') if (rejected) info('Updates were rejected')
// If the push failed for any reason other than being rejected, // If the push failed for any fatal reason other than being rejected,
// there is a problem // there is a problem
if (!rejected && pushResult.stderr) throw new Error(pushResult.stderr) if (!rejected && pushResult.stderr.trim().startsWith('fatal:'))
throw new Error(pushResult.stderr)
} while (rejected) } while (rejected)
} }
info(`Changes committed to the ${action.branch} branch… 📦`) info(`Changes committed to the ${action.branch} branch… 📦`)
if (action.tag) {
info(`Adding '${action.tag}' tag to the commit…`)
await execute(
`git tag ${action.tag}`,
`${action.workspace}/${temporaryDeploymentDirectory}`,
action.silent
)
info(`Pushing '${action.tag}' tag to repository…`)
await execute(
`git push origin ${action.tag}`,
`${action.workspace}/${temporaryDeploymentDirectory}`,
action.silent
)
info(
`Tag '${action.tag}' created and pushed to the ${action.branch} branch… 🏷️`
)
}
return Status.SUCCESS return Status.SUCCESS
} catch (error) { } catch (error) {
throw new Error( throw new Error(

View File

@ -1276,10 +1276,10 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d"
integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==
"@types/node@*", "@types/node@18.0.0", "@types/node@>= 8": "@types/node@*", "@types/node@18.0.6", "@types/node@>= 8":
version "18.0.0" version "18.0.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.0.0.tgz#67c7b724e1bcdd7a8821ce0d5ee184d3b4dd525a" resolved "https://registry.yarnpkg.com/@types/node/-/node-18.0.6.tgz#0ba49ac517ad69abe7a1508bc9b3a5483df9d5d7"
integrity sha512-cHlGmko4gWLVI27cGJntjs/Sj8th9aYwplmZFwmmgYQQvL5NUsgVJG7OddLvNfLqYS31KFN0s3qlaD9qCaxACA== integrity sha512-/xUq6H2aQm261exT6iZTMifUySEt4GR5KX8eYyY+C4MSNPqSh9oNIP7tz2GLKTlFaiBbgZNxffoR3CVRG+cljw==
"@types/normalize-package-data@^2.4.0": "@types/normalize-package-data@^2.4.0":
version "2.4.0" version "2.4.0"
@ -2152,10 +2152,10 @@ eslint-plugin-jest@26.5.3:
dependencies: dependencies:
"@typescript-eslint/utils" "^5.10.0" "@typescript-eslint/utils" "^5.10.0"
eslint-plugin-prettier@4.0.0: eslint-plugin-prettier@4.2.1:
version "4.0.0" version "4.2.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.0.0.tgz#8b99d1e4b8b24a762472b4567992023619cb98e0" resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz#651cbb88b1dab98bfd42f017a12fa6b2d993f94b"
integrity sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ== integrity sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ==
dependencies: dependencies:
prettier-linter-helpers "^1.0.0" prettier-linter-helpers "^1.0.0"