Compare commits
60 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a26f63b0ce | ||
|
|
a71372f9dd | ||
|
|
7bdc8af1b2 | ||
|
|
5c9f1f7cef | ||
|
|
d84d80e417 | ||
|
|
4d73263e3e | ||
|
|
b8f7f0eada | ||
|
|
75a30a545a | ||
|
|
401756f9f0 | ||
|
|
21ed6afecd | ||
|
|
388ce4f475 | ||
|
|
a2ca498476 | ||
|
|
60e7d47c17 | ||
|
|
4215dc951b | ||
|
|
33836ed288 | ||
|
|
6fcd798e4a | ||
|
|
50a62d9e15 | ||
|
|
9e04524704 | ||
|
|
6f812a4e2c | ||
|
|
f11ed1f3d2 | ||
|
|
ab2f7e88a9 | ||
|
|
7209b6038a | ||
|
|
b17846f438 | ||
|
|
da58dc8f9a | ||
|
|
4e0f991445 | ||
|
|
b71678be3e | ||
|
|
f21bebd7d3 | ||
|
|
d0143fb99e | ||
|
|
d192ad0aba | ||
|
|
3bee5aeb33 | ||
|
|
5cb8787442 | ||
|
|
334c6c32a5 | ||
|
|
d4b7879e16 | ||
|
|
d8573f888f | ||
|
|
cac5e6ba5b | ||
|
|
655a68b116 | ||
|
|
524f96d401 | ||
|
|
28ab8fcce3 | ||
|
|
6da0ea7f9b | ||
|
|
11a529635a | ||
|
|
bc31c50167 | ||
|
|
07e991cfab | ||
|
|
0f3c8c6996 | ||
|
|
0f070625cd | ||
|
|
ed8cbae509 | ||
|
|
4b5a2df0dd | ||
|
|
c8e1fb0d1b | ||
|
|
fe1fb219a6 | ||
|
|
28fa18d5af | ||
|
|
a0873811e5 | ||
|
|
40e84d601c | ||
|
|
ec13f51fd9 | ||
|
|
3140d34146 | ||
|
|
3ed8463058 | ||
|
|
ea1d3cefff | ||
|
|
e298441a67 | ||
|
|
4387feb4b8 | ||
|
|
cfa65e13b2 | ||
|
|
eb9afeffe2 | ||
|
|
110b7e289f |
@@ -145,7 +145,8 @@
|
||||
"avatar_url": "https://avatars1.githubusercontent.com/u/8356175?v=4",
|
||||
"profile": "https://github.com/Cyberbeni",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
"ideas",
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -174,6 +175,24 @@
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "ewjoachim",
|
||||
"name": "Joachim Jablon",
|
||||
"avatar_url": "https://avatars0.githubusercontent.com/u/1457576?v=4",
|
||||
"profile": "https://github.com/ewjoachim",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "trallnag",
|
||||
"name": "Tim Schwenke",
|
||||
"avatar_url": "https://avatars3.githubusercontent.com/u/24834206?v=4",
|
||||
"profile": "https://github.com/trallnag",
|
||||
"contributions": [
|
||||
"ideas"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 7,
|
||||
|
||||
64
.eslintrc
64
.eslintrc
@@ -1,64 +0,0 @@
|
||||
{
|
||||
"env": {
|
||||
"node": true,
|
||||
"browser": true,
|
||||
"amd": true,
|
||||
"es6": true
|
||||
},
|
||||
"root": true,
|
||||
"extends": [
|
||||
"eslint:recommended"
|
||||
],
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 6,
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
"no-cond-assign": [
|
||||
2,
|
||||
"except-parens"
|
||||
],
|
||||
"no-use-before-define": [
|
||||
2,
|
||||
{
|
||||
"functions": false,
|
||||
"classes": false,
|
||||
"variables": false
|
||||
}
|
||||
],
|
||||
"new-cap": 0,
|
||||
"no-caller": 2,
|
||||
"no-undef": 2,
|
||||
"no-unused-vars": 0,
|
||||
"@typescript-eslint/no-unused-vars": "warn",
|
||||
"no-empty": [
|
||||
"error",
|
||||
{
|
||||
"allowEmptyCatch": true
|
||||
}
|
||||
],
|
||||
"no-console": "off",
|
||||
"prefer-const": [
|
||||
"warn",
|
||||
{
|
||||
"destructuring": "all"
|
||||
}
|
||||
],
|
||||
"quotes": [
|
||||
"warn",
|
||||
"single"
|
||||
],
|
||||
"semi": [
|
||||
"warn",
|
||||
"never"
|
||||
],
|
||||
"spaced-comment": "warn"
|
||||
}
|
||||
}
|
||||
38
.eslintrc.js
Normal file
38
.eslintrc.js
Normal file
@@ -0,0 +1,38 @@
|
||||
module.exports = {
|
||||
env: {
|
||||
commonjs: true,
|
||||
es6: true,
|
||||
node: true
|
||||
},
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'prettier/@typescript-eslint',
|
||||
'plugin:prettier/recommended'
|
||||
],
|
||||
globals: {},
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
ecmaVersion: 6,
|
||||
sourceType: 'module'
|
||||
},
|
||||
plugins: ['@typescript-eslint'],
|
||||
rules: {
|
||||
'prettier/prettier': 'warn',
|
||||
'no-cond-assign': [2, 'except-parens'],
|
||||
'no-unused-vars': 0,
|
||||
'@typescript-eslint/no-unused-vars': 1,
|
||||
'no-empty': [
|
||||
'error',
|
||||
{
|
||||
allowEmptyCatch: true
|
||||
}
|
||||
],
|
||||
'prefer-const': [
|
||||
'warn',
|
||||
{
|
||||
destructuring: 'all'
|
||||
}
|
||||
],
|
||||
'spaced-comment': 'warn'
|
||||
}
|
||||
}
|
||||
10
.github/ISSUE_TEMPLATE/blank-issue.md
vendored
Normal file
10
.github/ISSUE_TEMPLATE/blank-issue.md
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
name: Blank issue
|
||||
about: Just a blank template
|
||||
title: ''
|
||||
labels: 'status: pending'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
24
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
24
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Report an issue with the action
|
||||
title: ''
|
||||
labels: 'status: pending'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is. If a particular error is shown
|
||||
|
||||
**Workflow used**
|
||||
Provide a snippet of the workflow and/or a link to it (use the commit sha as the ref when you link it, so that it's not influenced by other changes). If you only share a section of the workflow, make sure it includes the step that uses the action!
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Logs**
|
||||
Either provide a link to the action run or (if your repo is private) paste here the logs from the step that uses it. If you paste the logs, please use this template, and remember to paste the logs from all the different sections.
|
||||
<details>
|
||||
<summary>Logs</summary>
|
||||
<pre><code>Your logs here.</code></pre>
|
||||
</details>
|
||||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
blank_issues_enabled: false
|
||||
10
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
10
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
name: Question
|
||||
about: Ask a question on how to use the action
|
||||
title: ''
|
||||
labels: 'type: question'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
9
.github/workflows/build.yml
vendored
9
.github/workflows/build.yml
vendored
@@ -1,6 +1,8 @@
|
||||
name: Build
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- src/**
|
||||
- .github/workflows/build.yml
|
||||
@@ -27,10 +29,3 @@ jobs:
|
||||
add: lib
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: EndBug/add-and-commit@v4
|
||||
with:
|
||||
message: '[auto] build: update input typings'
|
||||
add: src/inputs.ts
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
4
.github/workflows/docs.yml
vendored
4
.github/workflows/docs.yml
vendored
@@ -1,6 +1,8 @@
|
||||
name: Docs
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- .all-contributorsrc
|
||||
- .github/workflows/docs.yml
|
||||
@@ -23,7 +25,7 @@ jobs:
|
||||
|
||||
- uses: EndBug/add-and-commit@v4.0.0
|
||||
with:
|
||||
message: "[auto] docs: update contributors badge"
|
||||
message: '[auto] docs: update contributors badge'
|
||||
add: README.md
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
2
.github/workflows/label-sync.yml
vendored
2
.github/workflows/label-sync.yml
vendored
@@ -1,6 +1,8 @@
|
||||
name: Sync labels
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- '.github/labels.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
22
.github/workflows/test.yml
vendored
Normal file
22
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
name: Test
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Test build
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: npm i
|
||||
- run: npm run build
|
||||
|
||||
lint:
|
||||
name: Check linting
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: npm i
|
||||
- run: npm run lint
|
||||
7
.prettierrc
Normal file
7
.prettierrc
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"trailingComma": "none"
|
||||
}
|
||||
82
CHANGELOG.md
82
CHANGELOG.md
@@ -1,4 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
@@ -6,125 +7,199 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [5.2.0] - 2020-11-11
|
||||
## [6.1.0] - 2020-12-22
|
||||
|
||||
### Added:
|
||||
|
||||
- `token` input: you can now use this instead of setting the `GITHUB_TOKEN` env variable, which has been deprecated. This input is optional, its default value is the default `secrets.GITHUB_TOKEN`. You only need to use this if you want the action to run with a PAT. (issue #110)
|
||||
|
||||
### Deprecated:
|
||||
|
||||
- `GITHUB_TOKEN`: the use of this env variable is now deprecated in favor of the `token` input, you'll start receiving warnings if you keep using it. (issue #110)
|
||||
|
||||
## [6.0.0] - 2020-12-22
|
||||
|
||||
### Added:
|
||||
|
||||
- (BREAKING?) Multiple git commands: support JSON/YAML arrays for the `add` and `remove` parameters (you still need pass a string as input, but that can be parsed to an array by the action). Using them will run multiple commands in succession. I don't think this will be really breaking anything, but I've used a major version change just to be sure. There's more info about this stuff on the README. (issue #95)
|
||||
|
||||
## [5.3.0] - 2020-12-12
|
||||
|
||||
### Added:
|
||||
|
||||
- Outputs: the action now has 3 outputs (`committed`, `pushed`, and `tagged`) that will be set to either `true` or `false` to tell you what the action has done. The outputs are also shown in the action logs.
|
||||
|
||||
## [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)
|
||||
|
||||
## [5.1.0] - 2020-10-07
|
||||
|
||||
### Added:
|
||||
|
||||
- The default commit message now displays the name of the workflow too (issue #64)
|
||||
|
||||
## [5.0.0] - 2020-09-27
|
||||
|
||||
### Changed:
|
||||
|
||||
- **[BREAKING]** Action parameters: multiple action parameters have been changed, refer to the docs for better info
|
||||
- The code is now entirely in TypeScript (PR #57)
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Improved input checks
|
||||
- Logs are now displayed on Windows too
|
||||
- Remove unnecessary steps
|
||||
- Remove unused dependencies
|
||||
|
||||
## [4.4.0] - 2020-07-31
|
||||
|
||||
### Added:
|
||||
|
||||
- Pull requests: the action can now work in runs triggered by pull request events (issue #48)
|
||||
|
||||
## [4.3.0] - 2020-07-29
|
||||
|
||||
### Addded:
|
||||
|
||||
- `signoff` parameter: lets you use the `--signoff` argument for the `git commit` command (PR #46)
|
||||
|
||||
## [4.2.1] - 2020-07-10
|
||||
|
||||
### Fixed:
|
||||
|
||||
- OS-support: the action now properly works on Windows instances (issue #33)
|
||||
|
||||
## [4.2.0] - 2020-05-17
|
||||
|
||||
### Added:
|
||||
|
||||
- Tagging: you can now create and update lightweight tags (PR #30)
|
||||
|
||||
## [4.1.0] - 2020-05-01
|
||||
|
||||
### Added:
|
||||
|
||||
- `ref` parameter: lets you choose the branch to run the action on, the default is the one that triggered the workflow (issue #29)
|
||||
|
||||
## [4.0.3] - 2020-05-01
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Logs: `git diff` won't display logs anymore, to avoid buffer problems (issue #27)
|
||||
- Logs: additional info will be logged along with the command outputs
|
||||
- Logs: added groups to improve readability
|
||||
|
||||
## [4.0.2] - 2020-04-19
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Error handling: failures are now easier to read (issue #25)
|
||||
|
||||
## [4.0.1] - 2020-03-20
|
||||
|
||||
### Fixed:
|
||||
|
||||
- Scheduled events: the action can be used in action runs triggered by a scheduled events
|
||||
- Warnings: there won't be warnings when both `author_name` and `author_email` are set
|
||||
|
||||
## [4.0.0] - 2020-03-03
|
||||
|
||||
### Removed:
|
||||
|
||||
- **[BREAKING]** `path` parameter: see 'Changed' section for more info
|
||||
- **[BREAKING]** `pattern` parameter: see 'Changed' section for more info
|
||||
|
||||
### Changed:
|
||||
|
||||
- The action now uses `git add` and `git rm` commands, you can choose their arguemnts directly by using the `add` and `remove` parameters
|
||||
- **[BREAKING]** Error handling: the action won't stop if one of your git commands fails (e.g. if one of your pathspecs doesn't match any file)
|
||||
|
||||
## [3.1.0] - 2020-02-21
|
||||
|
||||
### Added:
|
||||
|
||||
- `remove` parameter: lets you delete files directly from the action
|
||||
|
||||
## [3.0.0] - 2020-01-24
|
||||
|
||||
### Added:
|
||||
|
||||
- The action can now run in multiple subsequent jobs in the same workflow
|
||||
|
||||
### Removed:
|
||||
|
||||
- **[BREAKING]** [`actions/checkout@v1`](https://github.com/actions/checkout/tree/v1) support is being dropped in favor of [`actions/checkout@v2`](https://github.com/actions/checkout/releases/tag/v2)
|
||||
|
||||
## [2.3.2] - 2019-12-29
|
||||
|
||||
### Added:
|
||||
|
||||
- `cwd` parameter: lets you set the Current Working Directory
|
||||
|
||||
## [2.3.1] - 2019-12-20
|
||||
|
||||
### Added:
|
||||
|
||||
- Short tags: from now on, there will be short major tags available (`v2`, `v3`, ...)
|
||||
|
||||
## [2.3.0] - 2019-12-14
|
||||
|
||||
### Changed:
|
||||
|
||||
- TypeScript rewrite: the action will run faster because, unlike with Docker, no build process is needed
|
||||
|
||||
### Added:
|
||||
|
||||
- OS support: the action can now run in non-Linux environments too
|
||||
|
||||
## [2.2.0] - 2019-12-14
|
||||
|
||||
### Added:
|
||||
|
||||
- The action can automatically fetch the commit author to use
|
||||
- You can manually provide the author using the `author_name` and `author_email` parameters
|
||||
|
||||
## [2.1.1] - 2019-12-07
|
||||
|
||||
### Fixed:
|
||||
|
||||
- The action can now be used multiple times in the same workflow
|
||||
|
||||
## [2.1.0] - 2019-09-19
|
||||
|
||||
### Added:
|
||||
|
||||
- `force` parameter: uses `--force` when running `git add`
|
||||
|
||||
## [2.0.0] - 2019-09-18
|
||||
|
||||
### Changed:
|
||||
|
||||
- **[BREAKING]** The action now uses a `find` command
|
||||
|
||||
## [1.0.0] - 2019-09-17
|
||||
|
||||
First release
|
||||
|
||||
#
|
||||
[Unreleased]: https://github.com/EndBug/add-and-commit/compare/v5.2.0...HEAD
|
||||
|
||||
[unreleased]: https://github.com/EndBug/add-and-commit/compare/v5.3.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
|
||||
@@ -149,3 +224,6 @@ First release
|
||||
[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
|
||||
[5.3.0]: https://github.com/EndBug/add-and-commit/compare/v5.2.0...v5.3.0
|
||||
[6.0.0]: https://github.com/EndBug/add-and-commit/compare/v5.3.0...v6.0.0
|
||||
[6.1.0]: https://github.com/EndBug/add-and-commit/compare/v6.0.0...v6.1.0
|
||||
|
||||
56
README.md
56
README.md
@@ -1,6 +1,7 @@
|
||||
# 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>
|
||||
[](#contributors-)
|
||||
[](#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....
|
||||
|
||||
@@ -12,7 +13,7 @@ This action lets you choose the path that you want to use when adding & committi
|
||||
Add a step like this to your workflow:
|
||||
|
||||
```yaml
|
||||
- uses: EndBug/add-and-commit@v5 # You can change this to use a specific version
|
||||
- uses: EndBug/add-and-commit@v6 # You can change this to use a specific version
|
||||
with:
|
||||
# The arguments for the `git add` command (see the paragraph below for more info)
|
||||
# Default: '.'
|
||||
@@ -48,7 +49,7 @@ Add a step like this to your workflow:
|
||||
|
||||
# The arguments for the `git rm` command (see the paragraph below for more info)
|
||||
# Default: ''
|
||||
remove: "./dir/old_file.js"
|
||||
remove: './dir/old_file.js'
|
||||
|
||||
# Whether to use the --signoff option on `git commit` (only `true` and `false` are accepted)
|
||||
# Default: false
|
||||
@@ -56,32 +57,39 @@ Add a step like this to your workflow:
|
||||
|
||||
# Arguments for the git tag command (the tag name always needs to be the first word not preceded by an hyphen)
|
||||
# Default: ''
|
||||
tag: "v1.0.0 --force"
|
||||
tag: 'v1.0.0 --force'
|
||||
|
||||
env:
|
||||
# This is necessary in order to push a commit to the repo
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this line unchanged
|
||||
# Token to use for pushing the commit. The default value won't trigger any workflows, you need to use a Personal Access Token for that.
|
||||
# Default: secrets.GITHUB_TOKEN
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
### Environment variables:
|
||||
|
||||
The only `env` variable required is the token for the action to run: GitHub generates one automatically, but you need to pass it through `env` to make it available to actions. You can find more about `GITHUB_TOKEN` [here](https://help.github.com/en/articles/virtual-environments-for-github-actions#github_token-secret).
|
||||
That said, you can just copy the example line and not worry about it. If you do want to use a different token you can pass that in, but I wouldn't see any possible advantage in doing so.
|
||||
|
||||
### 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.
|
||||
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.
|
||||
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.
|
||||
|
||||
### Tagging:
|
||||
|
||||
You can use the `tag` option to enter the arguments for a `git add` command. In order for the action to isolate the tag name from the rest of the arguments, it should be the first word not preceded by an hyphen (e.g. `-a tag-name -m "some other stuff"` is ok).
|
||||
|
||||
### Outputs:
|
||||
|
||||
The action provides these outputs:
|
||||
|
||||
- `committed`: whether the action has created a commit (`'true'` or `'false'`)
|
||||
- `pushed`: whether the action has pushed to teh remote(`'true'` or `'false'`)
|
||||
- `tagged`: whether the action has created a tag (`'true'` or `'false'`)
|
||||
|
||||
For more info on how to use outputs, see ["Context and expression syntax"](https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions).
|
||||
|
||||
### Examples:
|
||||
|
||||
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:
|
||||
@@ -110,14 +118,12 @@ jobs:
|
||||
run: eslint "src/**" --fix
|
||||
|
||||
- name: Commit changes
|
||||
uses: EndBug/add-and-commit@v5
|
||||
uses: EndBug/add-and-commit@v6
|
||||
with:
|
||||
author_name: Your Name
|
||||
author_email: mail@example.com
|
||||
message: "Your commit message"
|
||||
add: "*.js"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
message: 'Your commit message'
|
||||
add: '*.js'
|
||||
```
|
||||
|
||||
If you need to run the action on a repository that is not located in [`$GITHUB_WORKSPACE`](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables#default-environment-variables), you can use the `cwd` option: the action uses a `cd` normal command, so the path should follow bash standards.
|
||||
@@ -135,19 +141,17 @@ jobs:
|
||||
# If you need to, you can check out your repo to a different location
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
path: "./pathToRepo/"
|
||||
path: './pathToRepo/'
|
||||
|
||||
# You can make whatever type of change to the repo...
|
||||
- run: echo "123" > ./pathToRepo/file.txt
|
||||
|
||||
# ...and then use the action as you would normally do, but providing the path to the repo
|
||||
- uses: EndBug/add-and-commit@v5
|
||||
- uses: EndBug/add-and-commit@v6
|
||||
with:
|
||||
message: "Add the very useful text file"
|
||||
add: "*.txt --force"
|
||||
cwd: "./pathToRepo/"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
message: 'Add the very useful text file'
|
||||
add: '*.txt --force'
|
||||
cwd: './pathToRepo/'
|
||||
```
|
||||
|
||||
## Contributors ✨
|
||||
@@ -177,10 +181,12 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
||||
<td align="center"><a href="http://hoten.cc"><img src="https://avatars1.githubusercontent.com/u/4071474?v=4" width="100px;" alt=""/><br /><sub><b>Connor Clark</b></sub></a><br /><a href="#ideas-connorjclark" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
</tr>
|
||||
<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/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> <a href="https://github.com/EndBug/add-and-commit/commits?author=Cyberbeni" title="Code">💻</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>
|
||||
<td align="center"><a href="https://github.com/ewjoachim"><img src="https://avatars0.githubusercontent.com/u/1457576?v=4" width="100px;" alt=""/><br /><sub><b>Joachim Jablon</b></sub></a><br /><a href="#ideas-ewjoachim" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
<td align="center"><a href="https://github.com/trallnag"><img src="https://avatars3.githubusercontent.com/u/24834206?v=4" width="100px;" alt=""/><br /><sub><b>Tim Schwenke</b></sub></a><br /><a href="#ideas-trallnag" title="Ideas, Planning, & Feedback">🤔</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
12
action.yml
12
action.yml
@@ -38,6 +38,18 @@ 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
|
||||
token:
|
||||
description: 'GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT)'
|
||||
required: false
|
||||
default: ${{ github.token }}
|
||||
|
||||
outputs:
|
||||
committed:
|
||||
description: Whether the action has created a commit.
|
||||
pushed:
|
||||
description: Whether the action has pushed to the remote.
|
||||
tagged:
|
||||
description: Whether the action has created a tag.
|
||||
|
||||
runs:
|
||||
using: node12
|
||||
|
||||
File diff suppressed because one or more lines are too long
122
package-lock.json
generated
122
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "add-and-commit",
|
||||
"version": "5.2.0",
|
||||
"version": "6.1.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@@ -63,6 +63,12 @@
|
||||
"integrity": "sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/js-yaml": {
|
||||
"version": "3.12.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-3.12.5.tgz",
|
||||
"integrity": "sha512-JCcp6J0GV66Y4ZMDAQCXot4xprYB+Zfd3meK9+INSJeVZwJmHAW30BBEEkPzXswMXuiyReUGOP3GxrADc9wPww==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/json-schema": {
|
||||
"version": "7.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.5.tgz",
|
||||
@@ -81,12 +87,6 @@
|
||||
"integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/yamljs": {
|
||||
"version": "0.2.31",
|
||||
"resolved": "https://registry.npmjs.org/@types/yamljs/-/yamljs-0.2.31.tgz",
|
||||
"integrity": "sha512-QcJ5ZczaXAqbVD3o8mw/mEBhRvO5UAdTtbvgwL/OgoWubvNBh6/MxLBAigtcgIFaq3shon9m3POIxQaLQt4fxQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/eslint-plugin": {
|
||||
"version": "2.34.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.34.0.tgz",
|
||||
@@ -158,9 +158,9 @@
|
||||
}
|
||||
},
|
||||
"@vercel/ncc": {
|
||||
"version": "0.25.1",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.25.1.tgz",
|
||||
"integrity": "sha512-dGecC5+1wLof1MQpey4+6i2KZv4Sfs6WfXkl9KfO32GED4ZPiKxRfvtGPjbjZv0IbqMl6CxtcV1RotXYfd5SSA==",
|
||||
"version": "0.26.1",
|
||||
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.26.1.tgz",
|
||||
"integrity": "sha512-iVhYAL/rpHgjO88GkDHNVNrp7WTfMFBbeWXNgwaDPMv5rDI4hNOAM0u+Zhtbs42XBQE6EccNaY6UDb/tm1+dhg==",
|
||||
"dev": true
|
||||
},
|
||||
"acorn": {
|
||||
@@ -298,7 +298,6 @@
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
@@ -457,6 +456,12 @@
|
||||
"yaml": "^1.10.0"
|
||||
}
|
||||
},
|
||||
"create-require": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
|
||||
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"cross-spawn": {
|
||||
"version": "6.0.5",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz",
|
||||
@@ -602,6 +607,24 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"eslint-config-prettier": {
|
||||
"version": "6.15.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.15.0.tgz",
|
||||
"integrity": "sha512-a1+kOYLR8wMGustcgAjdydMsQ2A/2ipRPwRKUmfYaSxc9ZPcrku080Ctl6zrZzZNs/U82MjSv+qKREkoq3bJaw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"get-stdin": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"eslint-plugin-prettier": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.0.tgz",
|
||||
"integrity": "sha512-tMTwO8iUWlSRZIwS9k7/E4vrTsfvsrcM5p1eftyuqWH25nKsz/o6/54I7jwQ/3zobISyC7wMy9ZsFwgTxOcOpQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"prettier-linter-helpers": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"eslint-scope": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz",
|
||||
@@ -641,8 +664,7 @@
|
||||
"esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
|
||||
"dev": true
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
|
||||
},
|
||||
"esquery": {
|
||||
"version": "1.1.0",
|
||||
@@ -691,6 +713,12 @@
|
||||
"integrity": "sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA==",
|
||||
"dev": true
|
||||
},
|
||||
"fast-diff": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz",
|
||||
"integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==",
|
||||
"dev": true
|
||||
},
|
||||
"fast-json-stable-stringify": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
|
||||
@@ -780,6 +808,12 @@
|
||||
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
|
||||
"dev": true
|
||||
},
|
||||
"get-stdin": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz",
|
||||
"integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==",
|
||||
"dev": true
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.6",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
|
||||
@@ -810,9 +844,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"husky": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/husky/-/husky-4.3.0.tgz",
|
||||
"integrity": "sha512-tTMeLCLqSBqnflBZnlVDhpaIMucSGaYyX6855jM4AguGeWCeSzNdb1mfyWduTZ3pe3SJVvVWGL0jO1iKZVPfTA==",
|
||||
"version": "4.3.6",
|
||||
"resolved": "https://registry.npmjs.org/husky/-/husky-4.3.6.tgz",
|
||||
"integrity": "sha512-o6UjVI8xtlWRL5395iWq9LKDyp/9TE7XMOTvIpEVzW638UcGxTmV5cfel6fsk/jbZSTlvfGVJf2svFtybcIZag==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^4.0.0",
|
||||
@@ -1053,10 +1087,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"js-yaml": {
|
||||
"version": "3.13.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
|
||||
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
|
||||
"dev": true,
|
||||
"version": "3.14.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
|
||||
"integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
|
||||
"requires": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
@@ -1387,6 +1420,21 @@
|
||||
"integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=",
|
||||
"dev": true
|
||||
},
|
||||
"prettier": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz",
|
||||
"integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==",
|
||||
"dev": true
|
||||
},
|
||||
"prettier-linter-helpers": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",
|
||||
"integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fast-diff": "^1.1.2"
|
||||
}
|
||||
},
|
||||
"progress": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",
|
||||
@@ -1518,13 +1566,23 @@
|
||||
"dev": true
|
||||
},
|
||||
"simple-git": {
|
||||
"version": "2.21.0",
|
||||
"resolved": "https://registry.npmjs.org/simple-git/-/simple-git-2.21.0.tgz",
|
||||
"integrity": "sha512-rohCHmEjD/ESXFLxF4bVeqgdb4Awc65ZyyuCKl3f7BvgMbZOBa/Ye3HN/GFnvruiUOAWWNupxhz3Rz5/3vJLTg==",
|
||||
"version": "2.27.0",
|
||||
"resolved": "https://registry.npmjs.org/simple-git/-/simple-git-2.27.0.tgz",
|
||||
"integrity": "sha512-/Q4aolzErYrIx6SgyH421jmtv5l1DaAw+KYWMWy229+isW6yld/nHGxJ2xUR/aeX3SuYJnbucyUigERwaw4Xow==",
|
||||
"requires": {
|
||||
"@kwsites/file-exists": "^1.1.1",
|
||||
"@kwsites/promise-deferred": "^1.1.1",
|
||||
"debug": "^4.1.1"
|
||||
"debug": "^4.3.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "4.3.1",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
|
||||
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
|
||||
"requires": {
|
||||
"ms": "2.1.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"slash": {
|
||||
@@ -1571,8 +1629,7 @@
|
||||
"sprintf-js": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
||||
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
|
||||
"dev": true
|
||||
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
|
||||
},
|
||||
"string-width": {
|
||||
"version": "4.2.0",
|
||||
@@ -1687,12 +1744,13 @@
|
||||
}
|
||||
},
|
||||
"ts-node": {
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.0.0.tgz",
|
||||
"integrity": "sha512-/TqB4SnererCDR/vb4S/QvSZvzQMJN8daAslg7MeaiHvD8rDZsSfXmNeNumyZZzMned72Xoq/isQljYSt8Ynfg==",
|
||||
"version": "9.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-9.1.1.tgz",
|
||||
"integrity": "sha512-hPlt7ZACERQGf03M253ytLY3dHbGNGrAq9qIHWUY9XHYl1z7wYngSr3OQ5xmui8o2AaxsONxIzjafLUiWBo1Fg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"arg": "^4.1.0",
|
||||
"create-require": "^1.1.0",
|
||||
"diff": "^4.0.1",
|
||||
"make-error": "^1.1.1",
|
||||
"source-map-support": "^0.5.17",
|
||||
@@ -1730,9 +1788,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"typescript": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.5.tgz",
|
||||
"integrity": "sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==",
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz",
|
||||
"integrity": "sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==",
|
||||
"dev": true
|
||||
},
|
||||
"uri-js": {
|
||||
|
||||
27
package.json
27
package.json
@@ -1,19 +1,20 @@
|
||||
{
|
||||
"name": "add-and-commit",
|
||||
"version": "5.2.0",
|
||||
"version": "6.1.0",
|
||||
"description": "Add & commit files from a path directly from GitHub Actions",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"build": "npm run inputs && ncc build src/main.ts --minify --out lib",
|
||||
"build": "ncc build src/main.ts --minify --out lib",
|
||||
"watch": "ncc build src/main.ts --watch --out lib",
|
||||
"lint": "eslint --ext .ts src",
|
||||
"lint:fix": "eslint --ext .ts --fix src",
|
||||
"all-contributors-badge": "ts-node scripts/all-contributors-badge",
|
||||
"changelog": "ts-node scripts/changelog.ts",
|
||||
"inputs": "ts-node scripts/inputs.ts",
|
||||
"changelog": "ts-node scripts/changelog.ts && npm i",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npm run build && git add src lib"
|
||||
"pre-commit": "npm run build && git add lib"
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
@@ -36,19 +37,23 @@
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"axios": "^0.21.0",
|
||||
"simple-git": "^2.21.0"
|
||||
"js-yaml": "^3.14.1",
|
||||
"simple-git": "^2.27.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^3.12.5",
|
||||
"@types/node": "^12.12.54",
|
||||
"@types/yamljs": "^0.2.31",
|
||||
"@typescript-eslint/eslint-plugin": "^2.34.0",
|
||||
"@typescript-eslint/parser": "^2.34.0",
|
||||
"@vercel/ncc": "^0.25.1",
|
||||
"@vercel/ncc": "^0.26.1",
|
||||
"all-contributors-cli": "^6.19.0",
|
||||
"eslint": "^6.8.0",
|
||||
"husky": "^4.3.0",
|
||||
"ts-node": "^9.0.0",
|
||||
"typescript": "^4.0.5",
|
||||
"eslint-config-prettier": "^6.15.0",
|
||||
"eslint-plugin-prettier": "^3.3.0",
|
||||
"husky": "^4.3.6",
|
||||
"prettier": "^2.2.1",
|
||||
"ts-node": "^9.1.1",
|
||||
"typescript": "^4.1.3",
|
||||
"yamljs": "^0.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,15 +6,19 @@ function path(...segments: string[]) {
|
||||
}
|
||||
|
||||
const README = fs.readFileSync(path('README.md'), { encoding: 'utf8' }),
|
||||
{ contributors } = JSON.parse(fs.readFileSync(path('.all-contributorsrc'), { encoding: 'utf8' }))
|
||||
{ contributors } = JSON.parse(
|
||||
fs.readFileSync(path('.all-contributorsrc'), { encoding: 'utf8' })
|
||||
)
|
||||
if (!(contributors instanceof Array)) throw new Error('Invalid config file')
|
||||
|
||||
const updatedREADME = README
|
||||
.split('\n')
|
||||
.map(line =>
|
||||
line.startsWith('[
|
||||
const updatedREADME = README.split('\n')
|
||||
.map((line) =>
|
||||
line.startsWith(
|
||||
'[
|
||||
? `[](#contributors-)`
|
||||
: line
|
||||
).join('\n')
|
||||
)
|
||||
.join('\n')
|
||||
|
||||
fs.writeFileSync(path('README.md'), updatedREADME)
|
||||
|
||||
@@ -2,7 +2,7 @@ import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
const currentVersion = require('../package.json').version
|
||||
if (!currentVersion) throw new Error('Cant\'t detect library version.')
|
||||
if (!currentVersion) throw new Error("Cant't detect library version.")
|
||||
|
||||
const changelogPath = path.resolve(__dirname, '../CHANGELOG.md')
|
||||
const changelog = fs.readFileSync(changelogPath, { encoding: 'utf-8' })
|
||||
@@ -12,7 +12,8 @@ let futureChangelog = ''
|
||||
|
||||
// Add version section
|
||||
let arr = changelog.split('## [Unreleased]')
|
||||
arr[1] = `
|
||||
arr[1] =
|
||||
`
|
||||
|
||||
## [${currentVersion}] - ${new Date().toISOString().slice(0, 10)}
|
||||
### Removed:
|
||||
@@ -28,13 +29,15 @@ futureChangelog = arr.join('## [Unreleased]')
|
||||
// Update footer
|
||||
arr = futureChangelog
|
||||
.split('\n')
|
||||
.map(line => line.startsWith('[Unreleased]')
|
||||
.map((line) =>
|
||||
line.startsWith('[Unreleased]')
|
||||
? `[Unreleased]: https://github.com/EndBug/add-and-commit/compare/v${currentVersion}...HEAD`
|
||||
: line)
|
||||
: line
|
||||
)
|
||||
|
||||
// eslint-disable-next-line no-useless-escape
|
||||
const lastVersion = ([...arr].reverse()[1]?.match(/\[([^\][]*)]/) || [])[0].replace(/[\[\]']+/g, '')
|
||||
if (!lastVersion) throw new Error('Can\'t find last version in changelog.')
|
||||
const lastVersion = ([...arr].reverse()[1]?.match(/\[([^\][]*)]/) ||
|
||||
[])[0].replace(/[\[\]']+/g, '') // eslint-disable-line no-useless-escape
|
||||
if (!lastVersion) throw new Error("Can't find last version in changelog.")
|
||||
|
||||
const lastLine = `[${currentVersion}]: https://github.com/EndBug/add-and-commit/compare/v${lastVersion}...v${currentVersion}`
|
||||
if (arr[arr.length - 1] === '') arr[arr.length - 1] = lastLine
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import YAML from 'yamljs'
|
||||
import fs from 'fs'
|
||||
|
||||
const actionManifest = YAML.load('action.yml'),
|
||||
inputs = Object.keys(actionManifest?.inputs || {})
|
||||
|
||||
fs.writeFileSync('src/inputs.ts', `
|
||||
// WARNING: this file is auto-generated by scripts/inputs.ts (npm run inputs), any manual edit will be overwritten.
|
||||
|
||||
export type Input = ${inputs.map(s => `'${s}'`).join(' | ')}
|
||||
`.trimLeft())
|
||||
@@ -1,3 +0,0 @@
|
||||
// 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' | 'push' | 'remove' | 'signoff' | 'tag'
|
||||
339
src/main.ts
339
src/main.ts
@@ -1,15 +1,21 @@
|
||||
import { info, setFailed, getInput as getInputCore, warning, debug, startGroup, endGroup, error } from '@actions/core'
|
||||
import {
|
||||
info,
|
||||
setFailed,
|
||||
warning,
|
||||
debug,
|
||||
startGroup,
|
||||
endGroup
|
||||
} from '@actions/core'
|
||||
import axios from 'axios'
|
||||
import path from 'path'
|
||||
import simpleGit, { Response } from 'simple-git'
|
||||
|
||||
import { Input } from './inputs'
|
||||
import YAML from 'js-yaml'
|
||||
import { getInput, Input, log, outputs, parseBool, setOutput } from './util'
|
||||
|
||||
const baseDir = path.join(process.cwd(), getInput('cwd') || '')
|
||||
const git = simpleGit({ baseDir })
|
||||
console.log(`Running in ${baseDir}`);
|
||||
|
||||
(async () => {
|
||||
console.log(`Running in ${baseDir}`)
|
||||
;(async () => {
|
||||
await checkInputs().catch(setFailed)
|
||||
|
||||
startGroup('Internal logs')
|
||||
@@ -33,7 +39,10 @@ console.log(`Running in ${baseDir}`);
|
||||
await git
|
||||
.addConfig('user.email', getInput('author_email'), undefined, log)
|
||||
.addConfig('user.name', getInput('author_name'), undefined, log)
|
||||
debug('> Current git config\n' + JSON.stringify((await git.listConfig()).all, null, 2))
|
||||
debug(
|
||||
'> Current git config\n' +
|
||||
JSON.stringify((await git.listConfig()).all, null, 2)
|
||||
)
|
||||
|
||||
await git.fetch(['--tags', '--force'], log)
|
||||
|
||||
@@ -43,43 +52,85 @@ console.log(`Running in ${baseDir}`);
|
||||
.catch(() => git.checkoutLocalBranch(getInput('branch'), log))
|
||||
|
||||
info('> Pulling from remote...')
|
||||
await git
|
||||
.fetch(undefined, log)
|
||||
.pull(undefined, undefined, {
|
||||
await git.fetch(undefined, log).pull(
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
[getInput('pull_strategy')]: null
|
||||
}, log)
|
||||
},
|
||||
log
|
||||
)
|
||||
|
||||
info('> Re-staging files...')
|
||||
if (getInput('add')) await add({ ignoreErrors: true })
|
||||
if (getInput('remove')) await remove({ ignoreErrors: true })
|
||||
|
||||
info('> Creating commit...')
|
||||
await git.commit(getInput('message'), undefined, {
|
||||
'--author': `"${getInput('author_name')} <${getInput('author_email')}>"`,
|
||||
...(getInput('signoff') ? {
|
||||
await git.commit(
|
||||
getInput('message'),
|
||||
undefined,
|
||||
{
|
||||
'--author': `"${getInput('author_name')} <${getInput(
|
||||
'author_email'
|
||||
)}>"`,
|
||||
...(getInput('signoff')
|
||||
? {
|
||||
'--signoff': null
|
||||
} : {})
|
||||
}, log)
|
||||
}
|
||||
: {})
|
||||
},
|
||||
(err, data?) => {
|
||||
if (data) setOutput('committed', 'true')
|
||||
return log(err, data)
|
||||
}
|
||||
)
|
||||
|
||||
if (getInput('tag')) {
|
||||
info('> Tagging commit...')
|
||||
await git.tag(getInput('tag').split(' '), log)
|
||||
await git
|
||||
.tag(getInput('tag').split(' '), (err, data?) => {
|
||||
if (data) setOutput('tagged', 'true')
|
||||
return log(err, data)
|
||||
})
|
||||
.then((data) => {
|
||||
setOutput('tagged', 'true')
|
||||
return log(null, data)
|
||||
})
|
||||
.catch((err) => setFailed(err))
|
||||
} else info('> No tag info provided.')
|
||||
|
||||
if (getInput('push')) {
|
||||
info('> Pushing commit to repo...')
|
||||
await git.push('origin', getInput('branch'), { '--set-upstream': null }, log)
|
||||
await git.push(
|
||||
'origin',
|
||||
getInput('branch'),
|
||||
{ '--set-upstream': null },
|
||||
(err, data?) => {
|
||||
if (data) setOutput('pushed', 'true')
|
||||
return log(err, data)
|
||||
}
|
||||
)
|
||||
|
||||
if (getInput('tag')) {
|
||||
info('> Pushing tags to repo...')
|
||||
await git.pushTags('origin', (e, d?) => log(undefined, e || d)).catch(() => {
|
||||
await git
|
||||
.pushTags('origin', undefined, (e, d?) => log(undefined, e || d))
|
||||
.catch(() => {
|
||||
info('> Tag push failed: deleting remote tag and re-pushing...')
|
||||
return git.push(undefined, undefined, {
|
||||
return git
|
||||
.push(
|
||||
undefined,
|
||||
undefined,
|
||||
{
|
||||
'--delete': null,
|
||||
'origin': null,
|
||||
[getInput('tag').split(' ').filter(w => !w.startsWith('-'))[0]]: null
|
||||
}, log)
|
||||
.pushTags('origin', log)
|
||||
origin: null,
|
||||
[getInput('tag')
|
||||
.split(' ')
|
||||
.filter((w) => !w.startsWith('-'))[0]]: null
|
||||
},
|
||||
log
|
||||
)
|
||||
.pushTags('origin', undefined, log)
|
||||
})
|
||||
} else info('> No tags to push.')
|
||||
} else info('> Not pushing anything.')
|
||||
@@ -90,14 +141,17 @@ console.log(`Running in ${baseDir}`);
|
||||
endGroup()
|
||||
info('> Working tree clean. Nothing to commit.')
|
||||
}
|
||||
})().catch(e => {
|
||||
})()
|
||||
.then(logOutputs)
|
||||
.catch((e) => {
|
||||
endGroup()
|
||||
logOutputs()
|
||||
setFailed(e)
|
||||
})
|
||||
})
|
||||
|
||||
async function checkInputs() {
|
||||
function setInput(input: Input, value: string | undefined) {
|
||||
if (value) return process.env[`INPUT_${input.toUpperCase()}`] = value
|
||||
if (value) return (process.env[`INPUT_${input.toUpperCase()}`] = value)
|
||||
else return delete process.env[`INPUT_${input.toUpperCase()}`]
|
||||
}
|
||||
function setDefault(input: Input, value: string) {
|
||||
@@ -107,38 +161,76 @@ async function checkInputs() {
|
||||
|
||||
const eventPath = process.env.GITHUB_EVENT_PATH,
|
||||
event = eventPath && require(eventPath),
|
||||
token = process.env.GITHUB_TOKEN,
|
||||
isPR = process.env.GITHUB_EVENT_NAME?.includes('pull_request'),
|
||||
sha = (event?.pull_request?.head?.sha || process.env.GITHUB_SHA) as string,
|
||||
defaultBranch = isPR
|
||||
? event?.pull_request?.head?.ref as string
|
||||
? (event?.pull_request?.head?.ref as string)
|
||||
: process.env.GITHUB_REF?.substring(11)
|
||||
|
||||
// #region GITHUB_TOKEN
|
||||
if (!token) warning('The GITHUB_TOKEN env variable is missing: the action may not work as expected.')
|
||||
let token = process.env.GITHUB_TOKEN
|
||||
if (token) {
|
||||
debug('Using token from GITHUB_TOKEN env variable.')
|
||||
warning(
|
||||
"The GITHUB_TOKEN env variable is deprecated and will not be supported in the next major release. Use the 'token' input, " +
|
||||
"which defaults to 'secrets.GITHUB_TOKEN'."
|
||||
)
|
||||
} else {
|
||||
debug('Using token from token input.')
|
||||
token = getInput('token')
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region add, remove
|
||||
if (!getInput('add') && !getInput('remove'))
|
||||
throw new Error('Both \'add\' and \'remove\' are empty, the action has nothing to do.')
|
||||
throw new Error(
|
||||
"Both 'add' and 'remove' are empty, the action has nothing to do."
|
||||
)
|
||||
|
||||
if (getInput('add')) {
|
||||
const parsed = parseInputArray(getInput('add'))
|
||||
if (parsed.length == 1)
|
||||
info('Add input parsed as single string, running 1 git add command.')
|
||||
else if (parsed.length > 1)
|
||||
info(
|
||||
`Add input parsed as string array, running ${parsed.length} git add commands.`
|
||||
)
|
||||
else 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.')
|
||||
else if (parsed.length > 1)
|
||||
info(
|
||||
`Remove input parsed as string array, running ${parsed.length} git rm commands.`
|
||||
)
|
||||
else setFailed('Remove input: array length < 1')
|
||||
}
|
||||
// #endregion
|
||||
|
||||
// #region author_name, author_email
|
||||
let author = event?.head_commit?.author
|
||||
if (sha && !author) {
|
||||
info('> Unable to get commit from workflow event: trying with the GitHub API...')
|
||||
info(
|
||||
'> Unable to get commit from workflow event: trying with the GitHub API...'
|
||||
)
|
||||
|
||||
// https://docs.github.com/en/rest/reference/repos#get-a-commit--code-samples
|
||||
const url = `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/commits/${sha}`,
|
||||
headers = token ? {
|
||||
headers = token
|
||||
? {
|
||||
Authorization: `Bearer ${token}`
|
||||
} : undefined,
|
||||
commit = (await axios.get(url, { headers }).catch(err => {
|
||||
}
|
||||
: undefined,
|
||||
commit = (
|
||||
await axios.get(url, { headers }).catch((err) => {
|
||||
startGroup('Request error:')
|
||||
info(`> Request URL: ${url}\b${err}`)
|
||||
endGroup()
|
||||
return undefined
|
||||
}))?.data
|
||||
})
|
||||
)?.data
|
||||
|
||||
author = commit?.commit?.author
|
||||
}
|
||||
@@ -163,11 +255,18 @@ async function checkInputs() {
|
||||
setDefault('author_email', 'actions@github.com')
|
||||
}
|
||||
|
||||
info(`> Using '${getInput('author_name')} <${getInput('author_email')}>' as author.`)
|
||||
info(
|
||||
`> Using '${getInput('author_name')} <${getInput(
|
||||
'author_email'
|
||||
)}>' as author.`
|
||||
)
|
||||
// #endregion
|
||||
|
||||
// #region message
|
||||
setDefault('message', `Commit from GitHub Actions (${process.env.GITHUB_WORKFLOW})`)
|
||||
setDefault(
|
||||
'message',
|
||||
`Commit from GitHub Actions (${process.env.GITHUB_WORKFLOW})`
|
||||
)
|
||||
info(`> Using "${getInput('message')}" as commit message.`)
|
||||
// #endregion
|
||||
|
||||
@@ -181,65 +280,151 @@ async function checkInputs() {
|
||||
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.`)
|
||||
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)
|
||||
if (!parsed) setInput('signoff', undefined)
|
||||
|
||||
debug(`Current signoff option: ${getInput('signoff')} (${typeof getInput('signoff')})`)
|
||||
debug(
|
||||
`Current signoff option: ${getInput('signoff')} (${typeof getInput(
|
||||
'signoff'
|
||||
)})`
|
||||
)
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
// #region push
|
||||
setDefault('push', 'true')
|
||||
if (getInput('push')) { // It's just to scope the parsed constant
|
||||
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.`)
|
||||
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)
|
||||
if (!parsed) setInput('push', undefined)
|
||||
|
||||
debug(`Current push option: ${getInput('push')} (${typeof getInput('push')})`)
|
||||
debug(
|
||||
`Current push option: ${getInput('push')} (${typeof getInput('push')})`
|
||||
)
|
||||
}
|
||||
// #endregion
|
||||
}
|
||||
|
||||
function getInput(name: Input) {
|
||||
return getInputCore(name)
|
||||
async function add({ logWarning = true, ignoreErrors = false } = {}): Promise<
|
||||
(void | Response<void>)[]
|
||||
> {
|
||||
const input = getInput('add')
|
||||
if (!input) return []
|
||||
|
||||
const parsed = parseInputArray(input)
|
||||
const res: (void | Response<void>)[] = []
|
||||
|
||||
for (const args of parsed) {
|
||||
res.push(
|
||||
// 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) =>
|
||||
log(ignoreErrors ? null : err, data)
|
||||
)
|
||||
.catch((e: Error) => {
|
||||
if (ignoreErrors) return
|
||||
if (
|
||||
e.message.includes('fatal: pathspec') &&
|
||||
e.message.includes('did not match any files') &&
|
||||
logWarning
|
||||
)
|
||||
warning(`Add command did not match any file:\n git add ${args}`)
|
||||
else throw e
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
function parseBool(value: any) {
|
||||
async function remove({
|
||||
logWarning = true,
|
||||
ignoreErrors = false
|
||||
} = {}): Promise<(void | Response<void>)[]> {
|
||||
const input = getInput('remove')
|
||||
if (!input) return []
|
||||
|
||||
const parsed = parseInputArray(input)
|
||||
const res: (void | Response<void>)[] = []
|
||||
|
||||
for (const args of parsed) {
|
||||
res.push(
|
||||
// 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) =>
|
||||
log(ignoreErrors ? null : e, d)
|
||||
)
|
||||
.catch((e: Error) => {
|
||||
if (ignoreErrors) return
|
||||
if (
|
||||
e.message.includes('fatal: pathspec') &&
|
||||
e.message.includes('did not match any files')
|
||||
)
|
||||
logWarning &&
|
||||
warning(
|
||||
`Remove command did not match any file:\n git rm ${args}`
|
||||
)
|
||||
else throw e
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to parse a JSON array, then a YAML array.
|
||||
* If both fail, it returns an array containing the input value as its only element
|
||||
*/
|
||||
function parseInputArray(input: string): string[] {
|
||||
try {
|
||||
const parsed = JSON.parse(value)
|
||||
if (typeof parsed == 'boolean')
|
||||
return parsed
|
||||
} catch { }
|
||||
const json = JSON.parse(input)
|
||||
if (
|
||||
json &&
|
||||
Array.isArray(json) &&
|
||||
json.every((e) => typeof e == 'string')
|
||||
) {
|
||||
debug(`Input parsed as JSON array of length ${json.length}`)
|
||||
return json
|
||||
}
|
||||
} catch {}
|
||||
|
||||
try {
|
||||
const yaml = YAML.safeLoad(input)
|
||||
if (
|
||||
yaml &&
|
||||
Array.isArray(yaml) &&
|
||||
yaml.every((e) => typeof e == 'string')
|
||||
) {
|
||||
debug(`Input parsed as YAML array of length ${yaml.length}`)
|
||||
return yaml
|
||||
}
|
||||
} catch {}
|
||||
|
||||
debug('Input parsed as single string')
|
||||
return [input]
|
||||
}
|
||||
|
||||
function log(err: any | Error, data?: any) {
|
||||
if (data) console.log(data)
|
||||
if (err) error(err)
|
||||
}
|
||||
|
||||
function add({ logWarning = true, ignoreErrors = false } = {}): Promise<void | Response<void>> | void {
|
||||
if (getInput('add'))
|
||||
return git.add(getInput('add').split(' '), (e: any, d?: any) => log(ignoreErrors ? null : e, d)).catch((e: Error) => {
|
||||
if (ignoreErrors) return
|
||||
if (e.message.includes('fatal: pathspec') && e.message.includes('did not match any files'))
|
||||
logWarning && warning('Add command did not match any file.')
|
||||
else throw e
|
||||
})
|
||||
}
|
||||
|
||||
function remove({ logWarning = true, ignoreErrors = false } = {}): Promise<void | Response<void>> | void {
|
||||
if (getInput('remove'))
|
||||
return git.rm(getInput('remove').split(' '), (e: any, d?: any) => log(ignoreErrors ? null : e, d)).catch((e: Error) => {
|
||||
if (ignoreErrors) return
|
||||
if (e.message.includes('fatal: pathspec') && e.message.includes('did not match any files'))
|
||||
logWarning && warning('Remove command did not match any file.')
|
||||
else throw e
|
||||
})
|
||||
function logOutputs() {
|
||||
startGroup('Outputs')
|
||||
for (const key in outputs) {
|
||||
info(`${key}: ${outputs[key]}`)
|
||||
}
|
||||
endGroup()
|
||||
}
|
||||
|
||||
45
src/util.ts
Normal file
45
src/util.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import * as core from '@actions/core'
|
||||
|
||||
export type Input =
|
||||
| 'add'
|
||||
| 'author_name'
|
||||
| 'author_email'
|
||||
| 'branch'
|
||||
| 'cwd'
|
||||
| 'message'
|
||||
| 'pull_strategy'
|
||||
| 'push'
|
||||
| 'remove'
|
||||
| 'signoff'
|
||||
| 'tag'
|
||||
| 'token'
|
||||
|
||||
export const outputs = {
|
||||
committed: 'false',
|
||||
pushed: 'false',
|
||||
tagged: 'false'
|
||||
}
|
||||
export type Output = keyof typeof outputs
|
||||
|
||||
export function getInput(name: Input) {
|
||||
return core.getInput(name)
|
||||
}
|
||||
|
||||
export function log(err: any | Error, data?: any) {
|
||||
if (data) console.log(data)
|
||||
if (err) core.error(err)
|
||||
}
|
||||
|
||||
export function parseBool(value: any) {
|
||||
try {
|
||||
const parsed = JSON.parse(value)
|
||||
if (typeof parsed == 'boolean') return parsed
|
||||
} catch {}
|
||||
}
|
||||
|
||||
export function setOutput(name: Output, value: 'true' | 'false') {
|
||||
core.debug(`Setting output: ${name}=${value}`)
|
||||
outputs[name] = value
|
||||
return core.setOutput(name, value)
|
||||
}
|
||||
for (const key in outputs) setOutput(key as Output, outputs[key])
|
||||
Reference in New Issue
Block a user