Compare commits

...

8 Commits

Author SHA1 Message Date
Federico Grandi
57c075ed5f release: v5.2.0 2020-11-11 18:34:50 +01:00
allcontributors[bot]
dd36cc6914 docs: add kbsali as a contributor (#91)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* [auto] docs: update contributors badge

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-11-11 18:29:40 +01:00
Federico Grandi
15f07d3078 [auto] build: update compiled version 2020-11-11 17:15:54 +00:00
Federico Grandi
c0c96adb24 docs(push): update docs for the push parameter 2020-11-11 18:15:00 +01:00
Federico Grandi
b36969554e feat(push): add push option
re #86
2020-11-11 18:11:50 +01:00
allcontributors[bot]
0c6f4a1284 docs: add Chocrates as a contributor (#90)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* [auto] docs: update contributors badge

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-11-10 15:44:24 +01:00
Federico Grandi
9358097a71 release: v5.1.2 2020-11-10 08:10:33 +01:00
dependabot[bot]
ed17cacb74 chore(deps-dev): bump @vercel/ncc from 0.24.1 to 0.25.1 (#87)
Bumps [@vercel/ncc](https://github.com/vercel/ncc) from 0.24.1 to 0.25.1.
- [Release notes](https://github.com/vercel/ncc/releases)
- [Commits](https://github.com/vercel/ncc/compare/0.24.1...0.25.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-11-09 22:52:04 +01:00
9 changed files with 95 additions and 29 deletions

View File

@@ -156,6 +156,24 @@
"contributions": [
"bug"
]
},
{
"login": "Chocrates",
"name": "Chris McIntosh",
"avatar_url": "https://avatars1.githubusercontent.com/u/1758164?v=4",
"profile": "https://github.com/Chocrates",
"contributions": [
"bug"
]
},
{
"login": "kbsali",
"name": "Kevin Saliou",
"avatar_url": "https://avatars0.githubusercontent.com/u/53676?v=4",
"profile": "https://github.com/kbsali",
"contributions": [
"ideas"
]
}
],
"contributorsPerLine": 7,

View File

@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [5.2.0] - 2020-11-11
### Added:
- New `push` option: this lets you tell the action whether to push commit and tags to the repo. The default value is `true`, so that the default behavior is not changed. (issue #86)
## [5.1.2] - 2020-11-10
### Fixed:
- Fixed an issue with the build (issue #88)
## [5.1.1] - 2020-11-07
### Fixed:
- Fixed typo in parameter name: `pull_strategy` was written as `pull_stategy` (PR #83)
@@ -116,7 +124,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
First release
#
[Unreleased]: https://github.com/EndBug/add-and-commit/compare/v5.1.1...HEAD
[Unreleased]: https://github.com/EndBug/add-and-commit/compare/v5.2.0...HEAD
[1.0.0]: https://github.com/EndBug/add-and-commit/tree/v1.0.0
[2.0.0]: https://github.com/EndBug/add-and-commit/compare/v1.0.0...v2.0.0
[2.1.0]: https://github.com/EndBug/add-and-commit/compare/v2.0.0...v2.1.0
@@ -139,3 +147,5 @@ First release
[5.0.0]: https://github.com/EndBug/add-and-commit/compare/v4.4.0...v5.0.0
[5.1.0]: https://github.com/EndBug/add-and-commit/compare/v5.0.0...v5.1.0
[5.1.1]: https://github.com/EndBug/add-and-commit/compare/v5.1.0...v5.1.1
[5.1.2]: https://github.com/EndBug/add-and-commit/compare/v5.1.1...v5.1.2
[5.2.0]: https://github.com/EndBug/add-and-commit/compare/v5.1.2...v5.2.0

View File

@@ -1,6 +1,6 @@
# Add & Commit
<a href="https://github.com/search?o=desc&q=EndBug%2Fadd-and-commit+path%3A.github%2Fworkflows+language%3AYAML&s=&type=Code" target="_blank" title="Public workflows that use this action."><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fapi-git-master.endbug.vercel.app%2Fapi%2Fgithub-actions%2Fused-by%3Faction%3DEndBug%2Fadd-and-commit%26badge%3Dtrue" alt="Public workflows that use this action."></a>
[![All Contributors](https://img.shields.io/badge/all_contributors-16-orange.svg?style=flat)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-18-orange.svg?style=flat)](#contributors-)
You can use this GitHub Action to commit changes made in your workflow run directly to your repo: for example, you use it to lint your code, update documentation, commit updated builds, etc....
@@ -42,6 +42,10 @@ Add a step like this to your workflow:
# Default: '--no-rebase'
pull_strategy: '--no-rebase or --no-ff or --rebase'
# Whether to push the commit and, if any, its tags to the repo (only `true` and `false` are accepted)
# Default: true
push: false
# The arguments for the `git rm` command (see the paragraph below for more info)
# Default: ''
remove: "./dir/old_file.js"
@@ -175,6 +179,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<tr>
<td align="center"><a href="https://github.com/Cyberbeni"><img src="https://avatars1.githubusercontent.com/u/8356175?v=4" width="100px;" alt=""/><br /><sub><b>Benedek Kozma</b></sub></a><br /><a href="#ideas-Cyberbeni" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center"><a href="https://github.com/coffeegoddd"><img src="https://avatars3.githubusercontent.com/u/43383835?v=4" width="100px;" alt=""/><br /><sub><b>Dustin Brown</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3Acoffeegoddd" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/Chocrates"><img src="https://avatars1.githubusercontent.com/u/1758164?v=4" width="100px;" alt=""/><br /><sub><b>Chris McIntosh</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3AChocrates" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://github.com/kbsali"><img src="https://avatars0.githubusercontent.com/u/53676?v=4" width="100px;" alt=""/><br /><sub><b>Kevin Saliou</b></sub></a><br /><a href="#ideas-kbsali" title="Ideas, Planning, & Feedback">🤔</a></td>
</tr>
</table>

View File

@@ -26,6 +26,9 @@ inputs:
description: The flag used on the pull strategy
required: false
default: '--no-rebase'
push:
description: Whether to push the commit and, if any, its tags to the repo
required: false
remove:
description: Arguments for the git rm command
required: false

File diff suppressed because one or more lines are too long

8
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "add-and-commit",
"version": "5.1.0",
"version": "5.2.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -158,9 +158,9 @@
}
},
"@vercel/ncc": {
"version": "0.24.1",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.24.1.tgz",
"integrity": "sha512-r9m7brz2hNmq5TF3sxrK4qR/FhXn44XIMglQUir4sT7Sh5GOaYXlMYikHFwJStf8rmQGTlvOoBXt4yHVonRG8A==",
"version": "0.25.1",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.25.1.tgz",
"integrity": "sha512-dGecC5+1wLof1MQpey4+6i2KZv4Sfs6WfXkl9KfO32GED4ZPiKxRfvtGPjbjZv0IbqMl6CxtcV1RotXYfd5SSA==",
"dev": true
},
"acorn": {

View File

@@ -1,6 +1,6 @@
{
"name": "add-and-commit",
"version": "5.1.1",
"version": "5.2.0",
"description": "Add & commit files from a path directly from GitHub Actions",
"main": "lib/index.js",
"scripts": {
@@ -43,7 +43,7 @@
"@types/yamljs": "^0.2.31",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"@vercel/ncc": "^0.24.1",
"@vercel/ncc": "^0.25.1",
"all-contributors-cli": "^6.19.0",
"eslint": "^6.8.0",
"husky": "^4.3.0",

View File

@@ -1,3 +1,3 @@
// WARNING: this file is auto-generated by scripts/inputs.ts (npm run inputs), any manual edit will be overwritten.
export type Input = 'add' | 'author_name' | 'author_email' | 'branch' | 'cwd' | 'message' | 'pull_strategy' | 'remove' | 'signoff' | 'tag'
export type Input = 'add' | 'author_name' | 'author_email' | 'branch' | 'cwd' | 'message' | 'pull_strategy' | 'push' | 'remove' | 'signoff' | 'tag'

View File

@@ -66,21 +66,23 @@ console.log(`Running in ${baseDir}`);
await git.tag(getInput('tag').split(' '), log)
} else info('> No tag info provided.')
info('> Pushing commit to repo...')
await git.push('origin', getInput('branch'), { '--set-upstream': null }, log)
if (getInput('push')) {
info('> Pushing commit to repo...')
await git.push('origin', getInput('branch'), { '--set-upstream': null }, log)
if (getInput('tag')) {
info('> Pushing tags to repo...')
await git.pushTags('origin', (e, d?) => log(undefined, e || d)).catch(() => {
info('> Tag push failed: deleting remote tag and re-pushing...')
return git.push(undefined, undefined, {
'--delete': null,
'origin': null,
[getInput('tag').split(' ').filter(w => !w.startsWith('-'))[0]]: null
}, log)
.pushTags('origin', log)
})
} else info('> No tags to push.')
if (getInput('tag')) {
info('> Pushing tags to repo...')
await git.pushTags('origin', (e, d?) => log(undefined, e || d)).catch(() => {
info('> Tag push failed: deleting remote tag and re-pushing...')
return git.push(undefined, undefined, {
'--delete': null,
'origin': null,
[getInput('tag').split(' ').filter(w => !w.startsWith('-'))[0]]: null
}, log)
.pushTags('origin', log)
})
} else info('> No tags to push.')
} else info('> Not pushing anything.')
endGroup()
info('> Task completed.')
@@ -175,13 +177,32 @@ async function checkInputs() {
// #endregion
// #region signoff
if (getInput('signoff')) try {
const parsed = JSON.parse(getInput('signoff'))
if (typeof parsed == 'boolean' && !parsed)
if (getInput('signoff')) {
const parsed = parseBool(getInput('signoff'))
if (parsed === undefined)
throw new Error(`"${getInput('signoff')}" is not a valid value for the 'signoff' input: only "true" and "false" are allowed.`)
if (!parsed)
setInput('signoff', undefined)
debug(`Current signoff option: ${getInput('signoff')} (${typeof getInput('signoff')})`)
} catch {
throw new Error(`"${getInput('signoff')}" is not a valid value for the 'signoff' input: only "true" and "false" are allowed.`)
}
// #endregion
// #region push
setDefault('push', 'true')
if (getInput('push')) { // It's just to scope the parsed constant
const parsed = parseBool(getInput('push'))
if (parsed === undefined)
throw new Error(`"${getInput('push')}" is not a valid value for the 'push' input: only "true" and "false" are allowed.`)
if (!parsed)
setInput('push', undefined)
debug(`Current push option: ${getInput('push')} (${typeof getInput('push')})`)
}
// #endregion
}
@@ -190,6 +211,14 @@ function getInput(name: Input) {
return getInputCore(name)
}
function parseBool(value: any) {
try {
const parsed = JSON.parse(value)
if (typeof parsed == 'boolean')
return parsed
} catch { }
}
function log(err: any | Error, data?: any) {
if (data) console.log(data)
if (err) error(err)