Compare commits

...

37 Commits

Author SHA1 Message Date
Federico Grandi
a3adef035a release: v7.2.0 2021-04-22 18:59:52 +02:00
allcontributors[bot]
e3d054462c docs: add ruohola as a contributor (#182)
* docs: update README.md [skip ci]

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

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-04-22 17:17:12 +02:00
Federico Grandi
ee9a9b3bd7 [auto] build: update compiled version 2021-04-22 15:16:38 +00:00
Federico Grandi
c698699df7 feat: add default_author (#181)
* feat: add deafult_author and start using actions-toolkit

* fix: go back to @actions/core for logs

* chore: add debug after fetching user

* test: keep build not minified

* fix: don't use tools.exit

* fix: author_displayname

* fix: check github_token

* fix: back to minified builds

* fix: fetch email too

* fix: change option names

* docs: document changes

* docs: update "github-actions" example
2021-04-22 17:15:47 +02:00
Federico Grandi
eb4e956492 [auto] build: update compiled version 2021-04-21 20:10:01 +00:00
Federico Grandi
5c12301e2f fix: rely on string-argv for git arg parsing (#180)
* fix: switch to string-argv for git args parsing

* chore: fix debug messages for matchGitArgs

* docs: add paragraph about git args parsing
2021-04-21 22:08:30 +02:00
dependabot[bot]
0d2694bccc chore(deps): bump js-yaml from 4.0.0 to 4.1.0 (#178)
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.0.0 to 4.1.0.
- [Release notes](https://github.com/nodeca/js-yaml/releases)
- [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nodeca/js-yaml/compare/4.0.0...4.1.0)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-19 09:52:52 +02:00
dependabot[bot]
7f40311aeb chore(deps-dev): bump eslint-plugin-prettier from 3.3.1 to 3.4.0 (#177)
Bumps [eslint-plugin-prettier](https://github.com/prettier/eslint-plugin-prettier) from 3.3.1 to 3.4.0.
- [Release notes](https://github.com/prettier/eslint-plugin-prettier/releases)
- [Changelog](https://github.com/prettier/eslint-plugin-prettier/blob/master/CHANGELOG.md)
- [Commits](https://github.com/prettier/eslint-plugin-prettier/commits)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-19 09:52:14 +02:00
Federico Grandi
c1404d189f chore: replace stale workflow with probot 2021-04-16 08:41:43 +02:00
Federico Grandi
3276c159ce release: v7.1.2 2021-04-16 08:22:42 +02:00
allcontributors[bot]
d10f775791 docs: add ruohola as a contributor (#175)
* docs: update README.md [skip ci]

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

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-04-16 08:16:40 +02:00
Federico Grandi
bc9a4cf987 fix: fix matchGitArgs (#174)
* fix: fix matchGitArgs

* fix: improve matchGitArgs

* chore: add ref in JSDoc
2021-04-16 08:15:25 +02:00
Federico Grandi
6d400479e9 fix(deps-dev): rollback @vercel/ncc
Version ^0.28.0 causes the action to fail.
Issue reported at https://github.com/vercel/ncc/issues/693
2021-04-14 21:01:09 +02:00
Federico Grandi
f519dbe2d8 chore: update build 2021-04-14 20:02:04 +02:00
Federico Grandi
7c4f8391e4 chore: update label config 2021-04-14 19:52:16 +02:00
dependabot[bot]
150689488d chore(deps-dev): bump eslint from 7.23.0 to 7.24.0 (#173)
Bumps [eslint](https://github.com/eslint/eslint) from 7.23.0 to 7.24.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v7.23.0...v7.24.0)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-14 19:50:21 +02:00
dependabot[bot]
3edff1c959 chore(deps-dev): bump @typescript-eslint/parser from 4.21.0 to 4.22.0 (#171)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.21.0 to 4.22.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.22.0/packages/parser)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-14 19:50:04 +02:00
dependabot[bot]
8a5bf1f2c3 chore(deps-dev): bump @vercel/ncc from 0.28.2 to 0.28.3 (#172)
Bumps [@vercel/ncc](https://github.com/vercel/ncc) from 0.28.2 to 0.28.3.
- [Release notes](https://github.com/vercel/ncc/releases)
- [Commits](https://github.com/vercel/ncc/compare/0.28.2...0.28.3)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-14 19:45:53 +02:00
dependabot[bot]
b7d8201cc4 chore(deps-dev): bump @typescript-eslint/eslint-plugin (#170)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.21.0 to 4.22.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.22.0/packages/eslint-plugin)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-14 19:44:12 +02:00
dependabot[bot]
d09e7e234b chore(deps): bump @actions/core from 1.2.6 to 1.2.7 (#169)
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.6 to 1.2.7.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-14 19:43:48 +02:00
dependabot[bot]
17dbbf433e chore(deps-dev): bump eslint-config-prettier from 8.1.0 to 8.2.0 (#168)
Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 8.1.0 to 8.2.0.
- [Release notes](https://github.com/prettier/eslint-config-prettier/releases)
- [Changelog](https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/eslint-config-prettier/compare/v8.1.0...v8.2.0)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-14 19:43:22 +02:00
Federico Grandi
95a1702b7a chore: update label config 2021-04-14 19:35:29 +02:00
dependabot[bot]
0d021d8d13 chore(deps-dev): bump eslint-config-prettier from 6.15.0 to 8.1.0 (#165)
* chore(deps-dev): bump eslint-config-prettier from 6.15.0 to 8.1.0

Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 6.15.0 to 8.1.0.
- [Release notes](https://github.com/prettier/eslint-config-prettier/releases)
- [Changelog](https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/eslint-config-prettier/compare/v6.15.0...v8.1.0)

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

* chore: update eslint config

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Federico Grandi <fgrandi30@gmail.com>
2021-04-12 08:35:16 +02:00
dependabot[bot]
0cbeea6850 chore(deps-dev): bump @typescript-eslint/eslint-plugin (#163)
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.20.0 to 4.21.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.21.0/packages/eslint-plugin)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Federico Grandi <fgrandi30@gmail.com>
2021-04-12 08:24:47 +02:00
dependabot[bot]
f7574eb56c chore(deps-dev): bump @vercel/ncc from 0.27.0 to 0.28.2 (#162)
* chore(deps-dev): bump @vercel/ncc from 0.27.0 to 0.28.2

Bumps [@vercel/ncc](https://github.com/vercel/ncc) from 0.27.0 to 0.28.2.
- [Release notes](https://github.com/vercel/ncc/releases)
- [Commits](https://github.com/vercel/ncc/compare/0.27.0...0.28.2)

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

* chore: use explicit moduleResolution

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Federico Grandi <fgrandi30@gmail.com>
2021-04-12 08:12:06 +02:00
dependabot[bot]
99d8a21c83 chore(deps-dev): bump typescript from 4.2.3 to 4.2.4 (#164)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.2.3 to 4.2.4.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.2.3...v4.2.4)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-12 08:05:41 +02:00
dependabot[bot]
913fd6894d chore(deps-dev): bump @typescript-eslint/parser from 4.20.0 to 4.21.0 (#161)
Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.20.0 to 4.21.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.21.0/packages/parser)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-12 08:00:18 +02:00
dependabot[bot]
de50d45399 chore(deps-dev): bump husky from 5.2.0 to 6.0.0 (#159)
Bumps [husky](https://github.com/typicode/husky) from 5.2.0 to 6.0.0.
- [Release notes](https://github.com/typicode/husky/releases)
- [Commits](https://github.com/typicode/husky/compare/v5.2.0...v6.0.0)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-05 13:32:36 +02:00
Federico Grandi
e7ec8bd868 chore(dev-deps): upgrade eslint 2021-04-05 13:30:54 +02:00
Federico Grandi
f1d41def84 release: v7.1.1 2021-04-04 12:33:30 +02:00
allcontributors[bot]
78d8443c62 docs: add xenoterracide as a contributor (#156)
* docs: update README.md [skip ci]

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

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-04-04 12:23:43 +02:00
Federico Grandi
e49da51881 docs(README): improve note about git error behavior 2021-04-03 15:59:05 +02:00
Federico Grandi
f4b07e6873 fix: improve git args parsing 2021-03-30 12:16:23 +02:00
dependabot[bot]
138434bf13 chore(deps-dev): bump husky from 5.1.3 to 5.2.0 (#153)
Bumps [husky](https://github.com/typicode/husky) from 5.1.3 to 5.2.0.
- [Release notes](https://github.com/typicode/husky/releases)
- [Commits](https://github.com/typicode/husky/compare/v5.1.3...v5.2.0)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-22 09:04:41 +01:00
Federico Grandi
51d91f68e3 docs: add warning regarding actions/checkout@v1
fix #146
2021-03-11 08:08:33 +01:00
dependabot[bot]
3e8da6e7cc chore(deps-dev): bump typescript from 4.2.2 to 4.2.3 (#152)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.2.2 to 4.2.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.2.2...v4.2.3)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-09 11:25:10 +01:00
dependabot[bot]
82ec483431 chore(deps-dev): bump husky from 5.1.2 to 5.1.3 (#151)
Bumps [husky](https://github.com/typicode/husky) from 5.1.2 to 5.1.3.
- [Release notes](https://github.com/typicode/husky/releases)
- [Commits](https://github.com/typicode/husky/compare/v5.1.2...v5.1.3)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-09 11:24:58 +01:00
15 changed files with 4900 additions and 738 deletions

View File

@@ -222,6 +222,25 @@
"contributions": [
"doc"
]
},
{
"login": "xenoterracide",
"name": "Caleb Cushing",
"avatar_url": "https://avatars.githubusercontent.com/u/5517?v=4",
"profile": "https://xenoterracide.com",
"contributions": [
"bug"
]
},
{
"login": "ruohola",
"name": "Eero Ruohola",
"avatar_url": "https://avatars.githubusercontent.com/u/33625218?v=4",
"profile": "https://ruohola.dev",
"contributions": [
"bug",
"ideas"
]
}
],
"contributorsPerLine": 7,

View File

@@ -4,11 +4,7 @@ module.exports = {
es6: true,
node: true
},
extends: [
'eslint:recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended'
],
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
globals: {},
parser: '@typescript-eslint/parser',
parserOptions: {

View File

@@ -13,4 +13,4 @@ updates:
prefix: 'chore'
include: 'scope'
labels:
- 'type: dependencies'
- 'type: chore'

62
.github/labels.yml vendored
View File

@@ -1,4 +1,3 @@
# General purpose
- name: 'good first issue'
color: '5319e7'
description: 'Good for newcomers'
@@ -11,70 +10,65 @@
- name: 'status: pending'
color: c5def5
description: 'More info is needed before deciding what to do.'
description: 'More info is needed before deciding what to do'
aliases: []
- name: 'status: pinned'
color: 0052cc
description: 'Issues and PRs that should not be labeled as stale or closed if they remain inactive.'
description: 'Should not be labeled as stale'
aliases: []
- name: 'status: stale'
color: fbca04
description: 'Inactive issues and PRs.'
description: 'Inactive issues and PRs'
aliases: ['stale']
- name: 'status: wontfix'
color: ffffff
description: 'This will not be worked on.'
color: cfd3d7
description: 'This will not be worked on'
aliases: ['wontfix']
- name: 'type: automation'
color: 2fc904
description: 'About actions workflows and automation.'
aliases: ['automation', 'actions']
- name: 'type: bug'
color: d73a4a
description: 'Verified problems that need to be worked on.'
description: 'Verified problems that need to be worked on'
aliases: ['bug']
- name: 'type: dependencies'
color: 0366d6
description: 'Pull requests that update a dependency file'
aliases: ['dependencies']
- name: 'type: chore'
color: C5DEF5
description: 'Code changes that neither fix bugs nor add features (refactoring, dependency chnages, ...)'
aliases: ['dependencies', 'type: dependencies', 'automation', 'type: automation']
- name: 'type: docs'
color: C5DEF5
description: "Documentation changes"
aliases: ['documentation', 'maintenance', 'type: maintenance']
- name: 'type: duplicate'
color: cfd3d7
description: 'This issue or pull request already exists.'
description: 'This issue or pull request already exists'
aliases: ['duplicate']
- name: 'type: enhancement'
color: a2eeef
description: 'New feature or request.'
aliases: ['enhancement']
- name: 'type: feature'
color: 0E8A16
description: 'New feature or feature request'
aliases: ['enhancement', 'type: enhancement']
- name: 'type: fix'
color: 1D76DB
description: 'Updates to existing functionalities'
aliases: ['fix']
- name: 'type: invalid'
color: e4e669
description: "This doesn't seem right."
description: "This doesn't seem right"
aliases: ['invalid']
- name: 'type: maintenance'
color: 0075ca
description: "Documentation improvements and code refactoring, doesn't affect functionality."
aliases: ['documentation', 'docs']
- name: 'type: not a bug'
color: 0e8a16
description: 'Reports that happen not be our fault.'
description: 'Reports that happen not be our fault'
aliases: ['not a bug']
- name: 'type: question'
color: d876e3
description: 'Further information is requested.'
description: 'Further information is requested'
aliases: ['question']
- name: 'type: security'
color: 'ee0701'
description: 'Pull requests that address a security vulnerability.'
aliases: ['security']

19
.github/stale.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 20
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 5
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
- 'status: pinned'
- 'type: security'
# Label to use when marking an issue as stale
staleLabel: 'status: stale'
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

View File

@@ -1,21 +0,0 @@
name: 'Handle stale issues and PRs'
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is being marked as "stale" because it has been open 20 days with no activity. Remove the "stale" label or comment, otherwise this will be closed in 5 days.'
stale-issue-label: 'status: stale'
exempt-issue-labels: 'status: pinned'
stale-pr-message: 'This PR is being marked as "stale" because it has been open 20 days with no activity. Remove the "stale" label or comment, otherwise this will be closed in 5 days.'
stale-pr-label: 'status: stale'
exempt-pr-labels: 'status: pinned'
days-before-stale: 20
days-before-close: 5

View File

@@ -7,6 +7,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [7.2.0] - 2021-04-22
### Added:
- `default_author`: this input allows you to control how the action fills missing author name or email (issue #167)
- `github_token` input introduced to get token to use in API calls
### Fixed:
- Git args are now parsed with [`string-argv`](https://npm.im/string-argv), the format has to comply with what the package can parse (issue #179)
## [7.1.2] - 2021-04-16
### Fixed:
- Git args parsing now correctly handles quotes, that can be used for multi-word arguments (issue #166)
## [7.1.1] - 2021-04-04
### Fixed:
- Git args parsing has been improved, and now handles spaces correctly (issue #154)
## [7.1.0] - 2021-03-03
### Added:
@@ -219,7 +242,7 @@ First release
#
[unreleased]: https://github.com/EndBug/add-and-commit/compare/v7.1.0...HEAD
[unreleased]: https://github.com/EndBug/add-and-commit/compare/v7.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
@@ -250,3 +273,6 @@ First release
[6.2.0]: https://github.com/EndBug/add-and-commit/compare/v6.1.0...v6.2.0
[7.0.0]: https://github.com/EndBug/add-and-commit/compare/v6.2.0...v7.0.0
[7.1.0]: https://github.com/EndBug/add-and-commit/compare/v7.0.0...v7.1.0
[7.1.1]: https://github.com/EndBug/add-and-commit/compare/v7.1.0...v7.1.1
[7.1.2]: https://github.com/EndBug/add-and-commit/compare/v7.1.1...v7.1.2
[7.2.0]: https://github.com/EndBug/add-and-commit/compare/v7.1.2...v7.2.0

View File

@@ -20,11 +20,11 @@ Add a step like this to your workflow:
add: 'src'
# The name of the user that will be displayed as the author of the commit
# Default: author of the commit that triggered the run
# Default: depends on the default_author input
author_name: Your Name
# The email of the user that will be displayed as the author of the commit
# Default: author of the commit that triggered the run
# Default: depends on the default_author input
author_email: mail@example.com
# Name of the branch to use, if different from the one that triggered the workflow
@@ -35,6 +35,13 @@ Add a step like this to your workflow:
# Default: '.'
cwd: './path/to/the/repo'
# Determines the way the action fills missing author name and email. Three options are available:
# - github_actor -> UserName <UserName@users.noreply.github.com>
# - user_info -> Your Display Name <your-actual@email.com>
# - github_actions -> github-actions <email associated with the github logo>
# Default:
default_author: github_actor
# The message for the commit
# Default: 'Commit from GitHub Actions (name of the workflow)'
message: 'Your commit message'
@@ -60,16 +67,21 @@ Add a step like this to your workflow:
tag: 'v1.0.0 --force'
```
### Git arguments
Multiple options let you provide the git arguments that you want the action to use. It's important to note that these arguments **are not actually used with a CLI command**, but they are parsed by a package called [`string-argv`](https://npm.im/string-argv), and then used with [`simple-git`](https://npm.im/simple-git).
What does this mean for you? It means that string that contain a lot of nested quotes may be parsed incorrectly, and that specific ways of declaring arguments may not be supported by this libraries. If you're having issues with your argument strings you can check whether they're being parsed correctly either by [enabling debug logging](https://docs.github.com/en/actions/managing-workflow-runs/enabling-debug-logging) for your workflow runs or by testing it directly with `string-argv` ([RunKit demo](https://npm.runkit.com/string-argv)): if each argument and option is aprsed correctly you'll see an array where every string is an option or value.
### Adding files:
The action adds files using a regular `git add` command, so you can put every kind of argument in the `add` option. For example, if you want to force-add a file: `./path/to/file.txt --force`.
The script will not stop if one of the git commands fails. E.g.: if your command shows a "fatal: pathspec 'yourFile' did not match any files" error the action will go on.
The script will not stop if one of the git commands doesn't match any file. E.g.: if your command shows a "fatal: pathspec 'yourFile' did not match any files" error the action will go on.
You can also use JSON or YAML arrays (e.g. `'["first", "second"]'`, `"['first', 'second']"`) to make the action run multiple `git add` commands: the action will log how your input has been parsed. Please mind that your input still needs to be a string because of how GitHub Actions works with inputs: just write your array inside the string, the action will parse it later.
### Deleting files:
You can delete files with the `remove` option: that runs a `git rm` command that will stage the files in the given path for removal. As with the `add` argument, you can use every option `git rm` allows (e.g. add `--force` to ignore `.gitignore` rules).
The script will not stop if one of the git commands fails. E.g.: if your command shows a "fatal: pathspec 'yourFile' did not match any files" error the action will go on.
The script will not stop if one of the git commands doesn't match any file. E.g.: if your command shows a "fatal: pathspec 'yourFile' did not match any files" error the action will go on.
You can also use JSON or YAML arrays (e.g. `'["first", "second"]'`, `"['first', 'second']"`) to make the action run multiple `git rm` commands: the action will log how your input has been parsed. Please mind that your input still needs to be a string because of how GitHub Actions works with inputs: just write your array inside the string, the action will parse it later.
### Pushing:
@@ -92,6 +104,19 @@ You can use the `tag` option to enter the arguments for a `git add` command. In
When pushing, the action uses the token that the local git repository has been configured with: that means that if you want to change it you'll need to do it in the steps that run before this action. For example: if you set up your repo with [`actions/checkout`](https://github.com/actions/checkout/) then you have to add the token there.
Changing the token with which the repo is configured can be useful if you want to run CI checks on the commit pushed by this action; anyway, it has to be set up outside of this action.
The action automatically gets the GitHub token from a `github_token` input: this input should not be modified by the user, since it doesn't affect the commits as it's only used to access the GitHub API to get user info, in case they selected that option for the commit author.
### About `actions/checkout`
The token you use when setting up the repo with this action will determine what token `add-and-commit` will use.
Some users reported that they were getting an error:
```
> fatal: could not read Username for 'https://github.com': No such device or address
```
If you're getting this error and you're using `actions/checkout@v1`, try upgrading to `actions/checkout@v2`. If you're still having problems after upgrading, feel free to open an issue. Issue ref: [#146](https://github.com/EndBug/add-and-commit/issues/146)
### Outputs:
The action provides these outputs:
@@ -104,7 +129,10 @@ For more info on how to use outputs, see ["Context and expression syntax"](https
### Examples:
If you don't want to use your GitHub username for the CI commits, you can [also use the user provided by GitHub for this task](https://github.com/actions/checkout/#push-a-commit-using-the-built-in-token):
If you don't want to use your GitHub username for the CI commits, you can use the `default_author` option to make it appear as if it was made by "github-actions"
<img src="https://user-images.githubusercontent.com/26386270/115738624-80b51780-a38d-11eb-9bbe-77461654274c.png" height=40/>
```yaml
on: push
jobs:
@@ -113,11 +141,9 @@ jobs:
steps:
- uses: EndBug/add-and-commit@v7.0.0
with:
author_name: github-actions
author_email: 41898282+github-actions[bot]@users.noreply.github.com
default_author: github_actions
```
`41898282+github-actions[bot]@users.noreply.github.com` is the mail of the original GitHub Actions bot. If you use that, [the GitHub avatar is shown for the commits](https://github.community/t/github-actions-bot-email-address/17204).
Do you want to lint your JavaScript files, located in the `src` folder, with ESLint, so that fixable changes are done without your intervention? You can use a workflow like this:
@@ -219,6 +245,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<tr>
<td align="center"><a href="https://dominikschilling.de"><img src="https://avatars2.githubusercontent.com/u/617637?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dominik Schilling</b></sub></a><br /><a href="#ideas-ocean90" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/EndBug/add-and-commit/commits?author=ocean90" title="Documentation">📖</a> <a href="https://github.com/EndBug/add-and-commit/commits?author=ocean90" title="Code">💻</a></td>
<td align="center"><a href="https://chaos.social/@rugk"><img src="https://avatars.githubusercontent.com/u/11966684?v=4?s=100" width="100px;" alt=""/><br /><sub><b>rugk</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/commits?author=rugk" title="Documentation">📖</a></td>
<td align="center"><a href="https://xenoterracide.com"><img src="https://avatars.githubusercontent.com/u/5517?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Caleb Cushing</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3Axenoterracide" title="Bug reports">🐛</a></td>
<td align="center"><a href="https://ruohola.dev"><img src="https://avatars.githubusercontent.com/u/33625218?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Eero Ruohola</b></sub></a><br /><a href="https://github.com/EndBug/add-and-commit/issues?q=author%3Aruohola" title="Bug reports">🐛</a> <a href="#ideas-ruohola" title="Ideas, Planning, & Feedback">🤔</a></td>
</tr>
</table>

View File

@@ -9,11 +9,9 @@ inputs:
author_name:
description: The name of the user that will be displayed as the author of the commit
required: false
default: ${{ github.actor }}
author_email:
description: The email of the user that will be displayed as the author of the commit
required: false
default: ${{ github.actor }}@users.noreply.github.com
branch:
description: Name of the branch to use, if different from the one that triggered the workflow
required: false
@@ -21,6 +19,10 @@ inputs:
description: The directory where your repository is located. You should use actions/checkout first to set it up
required: false
default: '.'
default_author:
description: How the action should fill missing author name or email.
required: false
default: 'github_actor'
message:
description: The message for the commit
required: false
@@ -41,6 +43,12 @@ inputs:
tag:
description: Arguments for the git tag command (the tag name always needs to be the first word not preceded by a hyphen)
required: false
# Input not required from the user
github_token:
description: The token used to make requests to the GitHub API. It's NOT used to make commits and should not be changed.
required: false
default: ${{ github.token }}
outputs:
committed:

2
lib/index.js generated

File diff suppressed because one or more lines are too long

5111
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "add-and-commit",
"version": "7.1.0",
"version": "7.2.0",
"private": true,
"description": "Add & commit files from a path directly from GitHub Actions",
"main": "lib/index.js",
@@ -31,24 +31,26 @@
},
"homepage": "https://github.com/EndBug/add-and-commit#readme",
"dependencies": {
"@actions/core": "^1.2.6",
"js-yaml": "^4.0.0",
"simple-git": "^2.27.0"
"@actions/core": "^1.2.7",
"actions-toolkit": "github:EndBug/actions-toolkit#core-actions",
"js-yaml": "^4.1.0",
"simple-git": "^2.27.0",
"string-argv": "^0.3.1"
},
"devDependencies": {
"@types/js-yaml": "^4.0.0",
"@types/node": "^12.12.54",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"@vercel/ncc": "^0.27.0",
"all-contributors-cli": "^6.20.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^3.3.1",
"husky": "^5.1.2",
"eslint": "^7.24.0",
"eslint-config-prettier": "^8.2.0",
"eslint-plugin-prettier": "^3.4.0",
"husky": "^6.0.0",
"prettier": "^2.2.1",
"ts-node": "^9.1.1",
"typescript": "^4.2.2",
"typescript": "^4.2.4",
"yamljs": "^0.3.0"
}
}

View File

@@ -1,58 +1,61 @@
import {
info,
setFailed,
warning,
debug,
startGroup,
endGroup
} from '@actions/core'
import * as core from '@actions/core'
import path from 'path'
import simpleGit, { Response } from 'simple-git'
import YAML from 'js-yaml'
import { getInput, Input, log, outputs, parseBool, setOutput } from './util'
import {
getInput,
getUserInfo,
Input,
log,
matchGitArgs,
parseBool,
setOutput,
tools
} from './util'
const baseDir = path.join(process.cwd(), getInput('cwd') || '')
const git = simpleGit({ baseDir })
console.log(`Running in ${baseDir}`)
core.info(`Running in ${baseDir}`)
;(async () => {
await checkInputs().catch(setFailed)
await checkInputs().catch(core.setFailed)
startGroup('Internal logs')
info('> Staging files...')
core.startGroup('Internal logs')
core.info('> Staging files...')
if (getInput('add')) {
info('> Adding files...')
core.info('> Adding files...')
await add()
} else info('> No files to add.')
} else core.info('> No files to add.')
if (getInput('remove')) {
info('> Removing files...')
core.info('> Removing files...')
await remove()
} else info('> No files to remove.')
} else core.info('> No files to remove.')
info('> Checking for uncommitted changes in the git working tree...')
core.info('> Checking for uncommitted changes in the git working tree...')
const changedFiles = (await git.diffSummary(['--cached'])).files.length
if (changedFiles > 0) {
info(`> Found ${changedFiles} changed files.`)
core.info(`> Found ${changedFiles} changed files.`)
await git
.addConfig('user.email', getInput('author_email'), undefined, log)
.addConfig('user.name', getInput('author_name'), undefined, log)
debug(
core.debug(
'> Current git config\n' +
JSON.stringify((await git.listConfig()).all, null, 2)
)
await git.fetch(['--tags', '--force'], log)
info('> Switching/creating branch...')
core.info('> Switching/creating branch...')
await git
.checkout(getInput('branch'), undefined, log)
.catch(() => git.checkoutLocalBranch(getInput('branch'), log))
if (getInput('pull_strategy') == 'NO-PULL') info('> Not pulling from repo.')
if (getInput('pull_strategy') == 'NO-PULL')
core.info('> Not pulling from repo.')
else {
info('> Pulling from remote...')
core.info('> Pulling from remote...')
await git.fetch(undefined, log).pull(
undefined,
undefined,
@@ -63,11 +66,11 @@ console.log(`Running in ${baseDir}`)
)
}
info('> Re-staging files...')
core.info('> Re-staging files...')
if (getInput('add')) await add({ ignoreErrors: true })
if (getInput('remove')) await remove({ ignoreErrors: true })
info('> Creating commit...')
core.info('> Creating commit...')
await git.commit(
getInput('message'),
undefined,
@@ -88,9 +91,9 @@ console.log(`Running in ${baseDir}`)
)
if (getInput('tag')) {
info('> Tagging commit...')
core.info('> Tagging commit...')
await git
.tag(getInput('tag').split(' '), (err, data?) => {
.tag(matchGitArgs(getInput('tag')), (err, data?) => {
if (data) setOutput('tagged', 'true')
return log(err, data)
})
@@ -98,16 +101,18 @@ console.log(`Running in ${baseDir}`)
setOutput('tagged', 'true')
return log(null, data)
})
.catch((err) => setFailed(err))
} else info('> No tag info provided.')
.catch((err) => core.setFailed(err))
} else core.info('> No tag info provided.')
const pushOption = parseBool(getInput('push')) ?? getInput('push')
if (pushOption) {
// If the options is `true | string`...
info('> Pushing commit to repo...')
core.info('> Pushing commit to repo...')
if (pushOption === true) {
debug(`Running: git push origin ${getInput('branch')} --set-upstream`)
core.debug(
`Running: git push origin ${getInput('branch')} --set-upstream`
)
await git.push(
'origin',
getInput('branch'),
@@ -118,11 +123,11 @@ console.log(`Running in ${baseDir}`)
}
)
} else {
debug(`Running: git push ${pushOption}`)
core.debug(`Running: git push ${pushOption}`)
await git.push(
undefined,
undefined,
pushOption.split(' '),
matchGitArgs(pushOption),
(err, data?) => {
if (data) setOutput('pushed', 'true')
return log(err, data)
@@ -131,11 +136,13 @@ console.log(`Running in ${baseDir}`)
}
if (getInput('tag')) {
info('> Pushing tags to repo...')
core.info('> Pushing tags to repo...')
await git
.pushTags('origin', undefined, (e, d?) => log(undefined, e || d))
.catch(() => {
info('> Tag push failed: deleting remote tag and re-pushing...')
core.info(
'> Tag push failed: deleting remote tag and re-pushing...'
)
return git
.push(
undefined,
@@ -143,29 +150,29 @@ console.log(`Running in ${baseDir}`)
{
'--delete': null,
origin: null,
[getInput('tag')
.split(' ')
.filter((w) => !w.startsWith('-'))[0]]: null
[matchGitArgs(getInput('tag')).filter(
(w) => !w.startsWith('-')
)[0]]: null
},
log
)
.pushTags('origin', undefined, log)
})
} else info('> No tags to push.')
} else info('> Not pushing anything.')
} else core.info('> No tags to push.')
} else core.info('> Not pushing anything.')
endGroup()
info('> Task completed.')
core.endGroup()
core.info('> Task completed.')
} else {
endGroup()
info('> Working tree clean. Nothing to commit.')
core.endGroup()
core.info('> Working tree clean. Nothing to commit.')
}
})()
.then(logOutputs)
.catch((e) => {
endGroup()
core.endGroup()
logOutputs()
setFailed(e)
core.setFailed(e)
})
async function checkInputs() {
@@ -194,32 +201,82 @@ async function checkInputs() {
if (getInput('add')) {
const parsed = parseInputArray(getInput('add'))
if (parsed.length == 1)
info('Add input parsed as single string, running 1 git add command.')
core.info('Add input parsed as single string, running 1 git add command.')
else if (parsed.length > 1)
info(
core.info(
`Add input parsed as string array, running ${parsed.length} git add commands.`
)
else setFailed('Add input: array length < 1')
else core.setFailed('Add input: array length < 1')
}
if (getInput('remove')) {
const parsed = parseInputArray(getInput('remove'))
if (parsed.length == 1)
info('Remove input parsed as single string, running 1 git rm command.')
core.info(
'Remove input parsed as single string, running 1 git rm command.'
)
else if (parsed.length > 1)
info(
core.info(
`Remove input parsed as string array, running ${parsed.length} git rm commands.`
)
else setFailed('Remove input: array length < 1')
else core.setFailed('Remove input: array length < 1')
}
// #endregion
// #region default_author
const default_author_valid = ['github_actor', 'user_info', 'github_actions']
if (!default_author_valid.includes(getInput('default_author')))
throw new Error(
`'${getInput(
'default_author'
)}' is not a valid value for default_author. Valid values: ${default_author_valid.join(
', '
)}`
)
// #region author_name, author_email
setDefault('author_name', `${process.env.GITHUB_ACTOR}`)
setDefault(
'author_email',
`${process.env.GITHUB_ACTOR}@users.noreply.github.com`
)
info(
let name, email
switch (getInput('default_author')) {
case 'github_actor': {
name = process.env.GITHUB_ACTOR
email = `${process.env.GITHUB_ACTOR}@users.noreply.github.com`
break
}
case 'user_info': {
if (!getInput('author_name') || !getInput('author_email')) {
const res = await getUserInfo(process.env.GITHUB_ACTOR)
if (!res?.name)
core.warning("Couldn't fetch author name, filling with github_actor.")
if (!res?.email)
core.warning(
"Couldn't fetch author email, filling with github_actor."
)
res?.name && (name = res?.name)
res?.email && (email = res.email)
if (name && email) break
}
!name && (name = process.env.GITHUB_ACTOR)
!email && (email = `${process.env.GITHUB_ACTOR}@users.noreply.github.com`)
break
}
case 'github_actions': {
name = 'github-actions'
email = '41898282+github-actions[bot]@users.noreply.github.com'
break
}
default:
throw new Error(
'This should not happen, please contact the author of this action. (checkInputs.author)'
)
}
setDefault('author_name', name)
setDefault('author_email', email)
core.info(
`> Using '${getInput('author_name')} <${getInput(
'author_email'
)}>' as author.`
@@ -231,12 +288,13 @@ async function checkInputs() {
'message',
`Commit from GitHub Actions (${process.env.GITHUB_WORKFLOW})`
)
info(`> Using "${getInput('message')}" as commit message.`)
core.info(`> Using "${getInput('message')}" as commit message.`)
// #endregion
// #region branch
const branch = setDefault('branch', defaultBranch || '')
if (isPR) info(`> Running for a PR, the action will use '${branch}' as ref.`)
if (isPR)
core.info(`> Running for a PR, the action will use '${branch}' as ref.`)
// #endregion
// #region signoff
@@ -252,7 +310,7 @@ async function checkInputs() {
if (!parsed) setInput('signoff', undefined)
debug(
core.debug(
`Current signoff option: ${getInput('signoff')} (${typeof getInput(
'signoff'
)})`
@@ -262,7 +320,7 @@ async function checkInputs() {
// #region pull_strategy
if (getInput('pull_strategy') == 'NO-PULL')
debug("NO-PULL found: won't pull from remote.")
core.debug("NO-PULL found: won't pull from remote.")
// #endregion
// #region push
@@ -270,11 +328,17 @@ async function checkInputs() {
// It has to be either 'true', 'false', or any other string (use as arguments)
const parsed = parseBool(getInput('push'))
debug(
core.debug(
`Current push option: '${getInput('push')}' (parsed as ${typeof parsed})`
)
}
// #endregion
// #region github_token
if (!getInput('github_token'))
core.warning(
'No github_token has been detected, the action may fail if it needs to use the API'
)
}
async function add({ logWarning = true, ignoreErrors = false } = {}): Promise<
@@ -291,7 +355,7 @@ async function add({ logWarning = true, ignoreErrors = false } = {}): Promise<
// Push the result of every git command (which are executed in order) to the array
// If any of them fails, the whole function will return a Promise rejection
await git
.add(args.split(' '), (err: any, data?: any) =>
.add(matchGitArgs(args), (err: any, data?: any) =>
log(ignoreErrors ? null : err, data)
)
.catch((e: Error) => {
@@ -301,7 +365,9 @@ async function add({ logWarning = true, ignoreErrors = false } = {}): Promise<
e.message.includes('did not match any files') &&
logWarning
)
warning(`Add command did not match any file:\n git add ${args}`)
core.warning(
`Add command did not match any file:\n git add ${args}`
)
else throw e
})
)
@@ -325,7 +391,7 @@ async function remove({
// Push the result of every git command (which are executed in order) to the array
// If any of them fails, the whole function will return a Promise rejection
await git
.rm(args.split(' '), (e: any, d?: any) =>
.rm(matchGitArgs(args), (e: any, d?: any) =>
log(ignoreErrors ? null : e, d)
)
.catch((e: Error) => {
@@ -335,7 +401,7 @@ async function remove({
e.message.includes('did not match any files')
)
logWarning &&
warning(
core.warning(
`Remove command did not match any file:\n git rm ${args}`
)
else throw e
@@ -358,7 +424,7 @@ function parseInputArray(input: string): string[] {
Array.isArray(json) &&
json.every((e) => typeof e == 'string')
) {
debug(`Input parsed as JSON array of length ${json.length}`)
core.debug(`Input parsed as JSON array of length ${json.length}`)
return json
}
} catch {}
@@ -370,19 +436,19 @@ function parseInputArray(input: string): string[] {
Array.isArray(yaml) &&
yaml.every((e) => typeof e == 'string')
) {
debug(`Input parsed as YAML array of length ${yaml.length}`)
core.debug(`Input parsed as YAML array of length ${yaml.length}`)
return yaml
}
} catch {}
debug('Input parsed as single string')
core.debug('Input parsed as single string')
return [input]
}
function logOutputs() {
startGroup('Outputs')
for (const key in outputs) {
info(`${key}: ${outputs[key]}`)
core.startGroup('Outputs')
for (const key in tools.outputs) {
core.info(`${key}: ${tools.outputs[key]}`)
}
endGroup()
core.endGroup()
}

View File

@@ -1,4 +1,6 @@
import { parseArgsStringToArgv } from 'string-argv'
import * as core from '@actions/core'
import { Toolkit } from 'actions-toolkit'
export type Input =
| 'add'
@@ -6,22 +8,49 @@ export type Input =
| 'author_email'
| 'branch'
| 'cwd'
| 'default_author'
| 'message'
| 'pull_strategy'
| 'push'
| 'remove'
| 'signoff'
| 'tag'
| 'github_token'
export const outputs = {
export type Output = 'committed' | 'pushed' | 'tagged'
type RecordOf<T extends string> = Record<T, string | undefined>
export const tools = new Toolkit<RecordOf<Input>, RecordOf<Output>>({
secrets: [
'GITHUB_EVENT_PATH',
'GITHUB_EVENT_NAME',
'GITHUB_REF',
'GITHUB_ACTOR'
]
})
tools.outputs = {
committed: 'false',
pushed: 'false',
tagged: 'false'
}
export type Output = keyof typeof outputs
export function getInput(name: Input) {
return core.getInput(name)
return tools.inputs[name] || ''
}
export async function getUserInfo(username?: string) {
if (!username) return undefined
const res = await tools.github.users.getByUsername({ username })
core.debug(
`Fetched github actor from the API: ${JSON.stringify(res?.data, null, 2)}`
)
return {
name: res?.data?.name,
email: res?.data?.email
}
}
export function log(err: any | Error, data?: any) {
@@ -29,6 +58,39 @@ export function log(err: any | Error, data?: any) {
if (err) core.error(err)
}
/**
* Matches the given string to an array of arguments.
* The parsing is made by `string-argv`: if your way of using argument is not supported, the issue is theirs!
* {@link https://www.npm.im/string-argv}
* @example
* ```js
* matchGitArgs(`
-s
--longOption 'This uses the "other" quotes'
--foo 1234
--file=message.txt
--file2="Application 'Support'/\"message\".txt"
`) => [
'-s',
'--longOption',
'This uses the "other" quotes',
'--foo',
'1234',
'--file=message.txt',
`--file2="Application 'Support'/\\"message\\".txt"`
]
* matchGitArgs(' ') => [ ]
* ```
* @returns An array, if there's no match it'll be empty
*/
export function matchGitArgs(string: string) {
const parsed = parseArgsStringToArgv(string)
core.debug(`Git args parsed:
- Original: ${string}
- Parsed: ${JSON.stringify(parsed)}`)
return parsed
}
export function parseBool(value: any) {
try {
const parsed = JSON.parse(value)
@@ -38,7 +100,5 @@ export function parseBool(value: any) {
export function setOutput(name: Output, value: 'true' | 'false') {
core.debug(`Setting output: ${name}=${value}`)
outputs[name] = value
return core.setOutput(name, value)
tools.outputs[name] = value
}
for (const key in outputs) setOutput(key as Output, outputs[key])

View File

@@ -35,7 +35,7 @@
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */