Skip to content

Commit

Permalink
Merge branch 'dev' into releases/v4
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesIves committed Jul 20, 2022
2 parents e6d003d + ccec059 commit f0e6e50
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Ignore artifacts:
build
coverage
coverage
lib
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</p>

<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>

## Getting Started :airplane:
Expand Down Expand Up @@ -128,7 +128,8 @@ run({
folder: 'build',
repositoryName: 'JamesIves/github-pages-deploy-action',
silent: true,
workspace: 'src/project/location'
workspace: 'src/project/location',
tag: 'v0.1'
})
```

Expand Down Expand Up @@ -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** |
| `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** |
| `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.

Expand Down
21 changes: 21 additions & 0 deletions __tests__/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
})
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
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:
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
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@jamesives/github-pages-deploy-action",
"description": "GitHub action for building a project and deploying it to GitHub pages.",
"author": "James Ives <iam@jamesiv.es> (https://jamesiv.es)",
"version": "4.3.3",
"version": "4.3.4",
"license": "MIT",
"main": "lib/lib.js",
"types": "lib/lib.d.ts",
Expand Down Expand Up @@ -42,13 +42,13 @@
},
"devDependencies": {
"@types/jest": "27.5.0",
"@types/node": "18.0.0",
"@types/node": "18.0.6",
"@typescript-eslint/eslint-plugin": "4.33.0",
"@typescript-eslint/parser": "4.33.0",
"eslint": "7.32.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-jest": "26.5.3",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-prettier": "4.2.1",
"jest": "26.6.3",
"jest-circus": "27.5.1",
"prettier": "2.7.1",
Expand Down
5 changes: 4 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export interface ActionInterface {
tokenType?: string
/** The folder where your deployment project lives. */
workspace: string
/** GitHub tag name */
tag?: string | null
}

/** The minimum required values to run the action as a node module. */
Expand Down Expand Up @@ -138,7 +140,8 @@ export const action: ActionInterface = {
? true
: getInput('ssh-key'),
targetFolder: getInput('target-folder'),
workspace: process.env.GITHUB_WORKSPACE || ''
workspace: process.env.GITHUB_WORKSPACE || '',
tag: getInput('tag')
}

/** Types for the required action parameters. */
Expand Down
24 changes: 22 additions & 2 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,34 @@ export async function deploy(action: ActionInterface): Promise<Status> {

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
if (!rejected && pushResult.stderr) throw new Error(pushResult.stderr)
if (!rejected && pushResult.stderr.trim().startsWith('fatal:'))
throw new Error(pushResult.stderr)
} while (rejected)
}

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
} catch (error) {
throw new Error(
Expand Down
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1276,10 +1276,10 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d"
integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==

"@types/node@*", "@types/node@18.0.0", "@types/node@>= 8":
version "18.0.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.0.0.tgz#67c7b724e1bcdd7a8821ce0d5ee184d3b4dd525a"
integrity sha512-cHlGmko4gWLVI27cGJntjs/Sj8th9aYwplmZFwmmgYQQvL5NUsgVJG7OddLvNfLqYS31KFN0s3qlaD9qCaxACA==
"@types/node@*", "@types/node@18.0.6", "@types/node@>= 8":
version "18.0.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.0.6.tgz#0ba49ac517ad69abe7a1508bc9b3a5483df9d5d7"
integrity sha512-/xUq6H2aQm261exT6iZTMifUySEt4GR5KX8eYyY+C4MSNPqSh9oNIP7tz2GLKTlFaiBbgZNxffoR3CVRG+cljw==

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
Expand Down Expand Up @@ -2152,10 +2152,10 @@ eslint-plugin-jest@26.5.3:
dependencies:
"@typescript-eslint/utils" "^5.10.0"

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

Expand Down

0 comments on commit f0e6e50

Please sign in to comment.