chore(deps): bump @actions/core from 1.2.7 to 1.3.0 (#203)

* chore(deps): bump @actions/core from 1.2.7 to 1.3.0

Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.7 to 1.3.0.
- [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>

* feat: switch to YAML boolean for inputs

The parsing is now handled by `@actions/core` package

* docs(README): minor changes

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Federico Grandi <fgrandi30@gmail.com>
This commit is contained in:
dependabot[bot]
2021-05-24 16:45:13 +02:00
committed by GitHub
parent bf5e32ae7d
commit b2ad943ed9
7 changed files with 40 additions and 35 deletions

View File

@@ -17,6 +17,7 @@ module.exports = {
'prettier/prettier': 'warn', 'prettier/prettier': 'warn',
'no-cond-assign': [2, 'except-parens'], 'no-cond-assign': [2, 'except-parens'],
'no-unused-vars': 0, 'no-unused-vars': 0,
'no-redeclare': 0,
'@typescript-eslint/no-unused-vars': 1, '@typescript-eslint/no-unused-vars': 1,
'no-empty': [ 'no-empty': [
'error', 'error',

View File

@@ -8,7 +8,7 @@ You can use this GitHub Action to commit changes made in your workflow run direc
This is **heavily** inspired by [git-auto-commit-action](https://github.com/stefanzweifel/git-auto-commit-action) (by [Stefan Zweifel](https://github.com/stefanzweifel)): that action automatically detects changed files and commits them. While this is useful for most situations, this doesn't commit untracked files and can sometimes commit unintended changes (such as `package-lock.json` or similar, that may have happened during previous steps). This is **heavily** inspired by [git-auto-commit-action](https://github.com/stefanzweifel/git-auto-commit-action) (by [Stefan Zweifel](https://github.com/stefanzweifel)): that action automatically detects changed files and commits them. While this is useful for most situations, this doesn't commit untracked files and can sometimes commit unintended changes (such as `package-lock.json` or similar, that may have happened during previous steps).
This action lets you choose the path that you want to use when adding & committing changes so that it works as you would normally do using `git` on your machine. This action lets you choose the path that you want to use when adding & committing changes so that it works as you would normally do using `git` on your machine.
## Usage ## Inputs
Add a step like this to your workflow: Add a step like this to your workflow:
@@ -58,7 +58,7 @@ Add a step like this to your workflow:
# Default: '' # 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) # Whether to use the --signoff option on `git commit` (only boolean values accepted*)
# Default: false # Default: false
signoff: true signoff: true
@@ -72,19 +72,19 @@ Add a step like this to your workflow:
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). 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. 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: ### 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 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 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. 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. 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: ### 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). 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 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. 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. 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: ### Pushing
By default the action runs the following command: `git push origin ${branch input} --set-upstream`. You can use the `push` input to modify this behavior, here's what you can set it to: By default the action runs the following command: `git push origin ${branch input} --set-upstream`. You can use the `push` input to modify this behavior, here's what you can set it to:
@@ -95,11 +95,11 @@ By default the action runs the following command: `git push origin ${branch inpu
One way to use this is if you want to force push to a branch of your repo: you'll need to set the `push` input to, for example, `origin yourBranch --force`. One way to use this is if you want to force push to a branch of your repo: you'll need to set the `push` input to, for example, `origin yourBranch --force`.
### Tagging: ### 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). 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).
### Tokens: ### Tokens
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. 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. 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.
@@ -117,7 +117,7 @@ Some users reported that they were getting an error:
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) 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: ## Outputs
The action provides these outputs: The action provides these outputs:
@@ -127,7 +127,7 @@ The action provides these outputs:
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). 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: ## Examples
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" 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"

6
lib/index.js generated

File diff suppressed because one or more lines are too long

14
package-lock.json generated
View File

@@ -8,7 +8,7 @@
"version": "7.2.1", "version": "7.2.1",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.7", "@actions/core": "^1.3.0",
"actions-toolkit": "github:EndBug/actions-toolkit#core-actions", "actions-toolkit": "github:EndBug/actions-toolkit#core-actions",
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"simple-git": "^2.27.0", "simple-git": "^2.27.0",
@@ -32,9 +32,9 @@
} }
}, },
"node_modules/@actions/core": { "node_modules/@actions/core": {
"version": "1.2.7", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.7.tgz", "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.3.0.tgz",
"integrity": "sha512-kzLFD5BgEvq6ubcxdgPbRKGD2Qrgya/5j+wh4LZzqT915I0V3rED+MvjH6NXghbvk1MXknpNNQ3uKjXSEN00Ig==" "integrity": "sha512-xxtX0Cwdhb8LcgatfJkokqT8KzPvcIbwL9xpLU09nOwBzaStbfm0dNncsP0M4us+EpoPdWy7vbzU5vSOH7K6pg=="
}, },
"node_modules/@actions/exec": { "node_modules/@actions/exec": {
"version": "1.0.4", "version": "1.0.4",
@@ -3308,9 +3308,9 @@
}, },
"dependencies": { "dependencies": {
"@actions/core": { "@actions/core": {
"version": "1.2.7", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.7.tgz", "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.3.0.tgz",
"integrity": "sha512-kzLFD5BgEvq6ubcxdgPbRKGD2Qrgya/5j+wh4LZzqT915I0V3rED+MvjH6NXghbvk1MXknpNNQ3uKjXSEN00Ig==" "integrity": "sha512-xxtX0Cwdhb8LcgatfJkokqT8KzPvcIbwL9xpLU09nOwBzaStbfm0dNncsP0M4us+EpoPdWy7vbzU5vSOH7K6pg=="
}, },
"@actions/exec": { "@actions/exec": {
"version": "1.0.4", "version": "1.0.4",

View File

@@ -31,7 +31,7 @@
}, },
"homepage": "https://github.com/EndBug/add-and-commit#readme", "homepage": "https://github.com/EndBug/add-and-commit#readme",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.7", "@actions/core": "^1.3.0",
"actions-toolkit": "github:EndBug/actions-toolkit#core-actions", "actions-toolkit": "github:EndBug/actions-toolkit#core-actions",
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"simple-git": "^2.27.0", "simple-git": "^2.27.0",

View File

@@ -9,7 +9,6 @@ import {
log, log,
matchGitArgs, matchGitArgs,
outputs, outputs,
parseBool,
readJSON, readJSON,
setOutput setOutput
} from './util' } from './util'
@@ -105,7 +104,12 @@ core.info(`Running in ${baseDir}`)
.catch((err) => core.setFailed(err)) .catch((err) => core.setFailed(err))
} else core.info('> No tag info provided.') } else core.info('> No tag info provided.')
const pushOption = parseBool(getInput('push')) ?? getInput('push') let pushOption: string | boolean
try {
pushOption = getInput('push', true)
} catch {
pushOption = getInput('push')
}
if (pushOption) { if (pushOption) {
// If the options is `true | string`... // If the options is `true | string`...
core.info('> Pushing commit to repo...') core.info('> Pushing commit to repo...')
@@ -301,7 +305,7 @@ async function checkInputs() {
// #region signoff // #region signoff
if (getInput('signoff')) { if (getInput('signoff')) {
const parsed = parseBool(getInput('signoff')) const parsed = getInput('signoff', true)
if (parsed === undefined) if (parsed === undefined)
throw new Error( throw new Error(
@@ -328,11 +332,15 @@ async function checkInputs() {
// #region push // #region push
if (getInput('push')) { if (getInput('push')) {
// It has to be either 'true', 'false', or any other string (use as arguments) // It has to be either 'true', 'false', or any other string (use as arguments)
const parsed = parseBool(getInput('push')) let value: string | boolean
core.debug( try {
`Current push option: '${getInput('push')}' (parsed as ${typeof parsed})` value = getInput('push', true)
) } catch {
value = getInput('push')
}
core.debug(`Current push option: '${value}' (parsed as ${typeof value})`)
} }
// #endregion // #endregion

View File

@@ -35,7 +35,10 @@ export const outputs: Record<Output, 'true' | 'false'> = {
tagged: 'false' tagged: 'false'
} }
export function getInput(name: Input) { export function getInput(name: Input, bool: true): boolean
export function getInput(name: Input, bool?: false): string
export function getInput(name: Input, bool = false) {
if (bool) return core.getBooleanInput(name)
return tools.inputs[name] || '' return tools.inputs[name] || ''
} }
@@ -92,13 +95,6 @@ export function matchGitArgs(string: string) {
return parsed return parsed
} }
export function parseBool(value: any) {
try {
const parsed = JSON.parse(value)
if (typeof parsed == 'boolean') return parsed
} catch {}
}
export function readJSON(filePath: string) { export function readJSON(filePath: string) {
let fileContent: string let fileContent: string
try { try {