Compare commits

..

13 Commits

Author SHA1 Message Date
Federico Grandi
45c7fd7a48 Commit dist files 2020-03-03 19:32:47 +01:00
Federico Grandi
06fd39b8b7 Fix typo 2020-03-03 19:31:46 +01:00
Federico Grandi
f278ec6d47 Trigger workflow run 2020-03-03 19:30:13 +01:00
Federico Grandi
5a3f4c1c24 Update build workflow 2020-03-03 19:29:21 +01:00
Federico Grandi
602bf4ea71 Final adjustments for v4 2020-03-03 19:28:06 +01:00
Federico Grandi
5148cf0f38 Use set -u instead of -eu 2020-03-03 19:04:22 +01:00
Federico Grandi
12febc42d8 Use git add 2020-03-03 18:36:41 +01:00
Federico Grandi
de8a121ebd Rm (#20)
* Add remove option

* [auto] Update compiled version

* Add fixes

* [auto] Update compiled version

* Update docs
2020-02-21 16:48:19 +01:00
Federico Grandi
a2b49385e8 [auto] Update compiled version 2020-02-11 20:31:49 +00:00
Federico Grandi
ea7cddff4f Better usage docs 2020-02-03 17:12:00 +01:00
Federico Grandi
9acdb7d7f4 Small refactor 2020-02-03 16:54:41 +01:00
Federico Grandi
6d08b4f153 Add setDefault function 2020-02-03 16:53:01 +01:00
Federico Grandi
925751a406 Update versioning.yml 2020-01-24 10:52:35 +01:00
29 changed files with 126 additions and 141 deletions

View File

@@ -3,6 +3,8 @@ on:
push: push:
branches-ignore: branches-ignore:
- dist - dist
paths:
- src/**
jobs: jobs:
build: build:

View File

@@ -2,7 +2,7 @@ name: Keep the versions up-to-date
on: on:
release: release:
types: [published] types: [published, edited]
jobs: jobs:
actions-tagger: actions-tagger:

View File

@@ -10,53 +10,55 @@ This action lets you choose the path that you want to use when adding & committi
Add a step like this to your workflow: Add a step like this to your workflow:
```yaml ```yaml
- name: Commit changes # This is the step name that will be displayed in your runs - uses: EndBug/add-and-commit@v4 # You can change this to use a specific version
uses: EndBug/add-and-commit@v2 # You can change this to use a specific version with:
with: # See more info about inputs below # The arguments for the git add command (see the paragraph below for more info)
# Default: '.'
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
author_name: Your Name author_name: Your Name
# The The email of the user that will be displayed as the author of the commit
# Default: author of the commit that triggered the run
author_email: mail@example.com author_email: mail@example.com
cwd: "."
message: "Your commit message" # The local path to the directory where your repository is located. You should use actions/checkout first to set it up
path: "." # Default: '.'
pattern: "*.js" cwd: './path/to/the/repo'
force: false
# Whether to use the --force option on git add, in order to bypass eventual gitignores
# Default: false
force: true
# The message for the commit
# Default: 'Commit from GitHub Actions'
message: 'Your commit message'
# The arguments for the git rm command (see the paragraph below for more info)
# Default: ''
remove: "./dir/old_file.js"
env: env:
# This is necessary in order to push a commit to the repo
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this line unchanged GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this line unchanged
``` ```
### Inputs:
- `author_name` : the name of the user that will be displayed as the author of the commit, defaults to the author of the commit that triggered the run
- `author_email` : the email of the user that will be displayed as the author of the commit, defaults to the author of the commit that triggered the run
- `cwd` : the working directory in which your repository is located, defaults to `.`
- `message` : the message for the commit
- `path` : the path(s) to stage files from
- `pattern` : the pattern that matches file names
- `force` : whether to use the force option on git add, in order to bypass eventual gitignores
### Environment variables: ### 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). 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).
With that said, you can just copy the example line and don't 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. With that said, you can just copy the example line and don't 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 don't want it to use a recursive behavior: `$(find . -maxdepth 1 -name *.js)`.
The script will not stop if one 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.
### Deleting files: ### Deleting files:
This action only **adds** files so in order to commit a file deletion you need to stage that separately: for that, you can run `git rm` in a previous step. Here's a quick example: 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.
The script will not stop if one 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.
```yaml
- run: git rm delete_me.txt
- uses: EndBug/add-and-commit@v2
with:
author_name: Your Name
author_email: mail@example.com
message: "Remove file"
path: "."
pattern: "*.js" # The path is not important, the file will get removed anyway: that means you can still use the action as usual
force: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
### Examples: ### Examples:
@@ -86,13 +88,12 @@ jobs:
run: eslint "src/**" --fix run: eslint "src/**" --fix
- name: Commit changes - name: Commit changes
uses: EndBug/add-and-commit@v2 uses: EndBug/add-and-commit@v4
with: with:
author_name: Your Name author_name: Your Name
author_email: mail@example.com author_email: mail@example.com
message: "Your commit message" message: "Your commit message"
path: "." add: "*.js"
pattern: "*.js"
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```
@@ -118,11 +119,10 @@ jobs:
- run: echo "123" > ./pathToRepo/file.txt - run: echo "123" > ./pathToRepo/file.txt
# ...and then use the action as you would normally do, but providing the path to the repo # ...and then use the action as you would normally do, but providing the path to the repo
- uses: EndBug/add-and-commit@v2 - uses: EndBug/add-and-commit@v4
with: with:
message: "Add the very useful text file" message: "Add the very useful text file"
path: "." add: "*.txt"
pattern: "*.txt"
cwd: "./pathToRepo/" cwd: "./pathToRepo/"
force: true force: true
env: env:

View File

@@ -2,6 +2,10 @@ name: Add & Commit
description: Add & commit files from a path directly from GitHub Actions description: Add & commit files from a path directly from GitHub Actions
inputs: inputs:
add:
description: Arguments for the git add command
required: false
default: "."
author_name: author_name:
description: The name of the user that will be displayed as the author of the commit description: The name of the user that will be displayed as the author of the commit
required: false required: false
@@ -20,14 +24,10 @@ inputs:
description: The message for the commit description: The message for the commit
required: false required: false
default: Commit from GitHub Actions default: Commit from GitHub Actions
path: remove:
description: The path to stage files from description: Arguments for the git rm command
required: false required: false
default: "." default: ""
pattern:
description: The pattern that mathces file names
required: false
default: "*.*"
runs: runs:
using: node12 using: node12

View File

@@ -1 +1 @@
"use strict";var __importStar=this&&this.__importStar||function(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b["default"]=a,b};Object.defineProperty(exports,"__esModule",{value:!0});const core=__importStar(require("@actions/core")),shell=__importStar(require("shelljs")),path=__importStar(require("path"));try{checkInputs(),shell.exec(path.join(__dirname,"../src/entrypoint.sh"))}catch(a){core.setFailed(a)}function checkInputs(){const a=process.env.GITHUB_EVENT_PATH;if(a){const{author:b}=require(a).head_commit;process.env.INPUT_AUTHOR_NAME||(process.env.INPUT_AUTHOR_NAME=b.name),process.env.INPUT_AUTHOR_EMAIL||(process.env.INPUT_AUTHOR_EMAIL=b.email)}else core.warning("No event path available, unable to fetch author info."),process.env.INPUT_AUTHOR_NAME||(process.env.INPUT_AUTHOR_NAME="Add & Commit Action"),process.env.INPUT_AUTHOR_EMAIL||(process.env.INPUT_AUTHOR_EMAIL="actions@github.com");core.info(`Using '${process.env.INPUT_AUTHOR_NAME} <${process.env.INPUT_AUTHOR_EMAIL}>' as author.`)} "use strict";var __importStar=this&&this.__importStar||function(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b["default"]=a,b};Object.defineProperty(exports,"__esModule",{value:!0});const core=__importStar(require("@actions/core")),shell=__importStar(require("shelljs")),path=__importStar(require("path"));try{checkInputs(),shell.exec(path.join(__dirname,"../src/entrypoint.sh"))}catch(a){core.setFailed(a)}function checkInputs(){const a=process.env.GITHUB_EVENT_PATH;if(a){const{author:b}=require(a).head_commit;setDefault("author_name",b.name),setDefault("author_email",b.email)}else core.warning("No event path available, unable to fetch author info."),setDefault("author_name","Add & Commit Action"),setDefault("author_email","actions@github.com");core.info(`Using '${core.getInput("author_name")} <${core.getInput("author_email")}>' as author.`)}function setDefault(a,b){const c="INPUT_"+a.toUpperCase();process.env[c]||(process.env[c]=b)}

2
node_modules/.bin/shjs generated vendored
View File

@@ -2,7 +2,7 @@
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac esac
if [ -x "$basedir/node" ]; then if [ -x "$basedir/node" ]; then

22
node_modules/.bin/shjs.cmd generated vendored
View File

@@ -1,17 +1,7 @@
@ECHO off @IF EXIST "%~dp0\node.exe" (
SETLOCAL "%~dp0\node.exe" "%~dp0\..\shelljs\bin\shjs" %*
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE ( ) ELSE (
SET "_prog=node" @SETLOCAL
SET PATHEXT=%PATHEXT:;.JS;=;% @SET PATHEXT=%PATHEXT:;.JS;=;%
) node "%~dp0\..\shelljs\bin\shjs" %*
)
"%_prog%" "%dp0%\..\shelljs\bin\shjs" %*
ENDLOCAL
EXIT /b %errorlevel%
:find_dp0
SET dp0=%~dp0
EXIT /b

18
node_modules/.bin/shjs.ps1 generated vendored
View File

@@ -1,18 +0,0 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
& "$basedir/node$exe" "$basedir/../shelljs/bin/shjs" $args
$ret=$LASTEXITCODE
} else {
& "node$exe" "$basedir/../shelljs/bin/shjs" $args
$ret=$LASTEXITCODE
}
exit $ret

View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"@actions/core@1.2.0", "@actions/core@1.2.0",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "@actions/core@1.2.0", "_from": "@actions/core@1.2.0",
@@ -27,7 +27,7 @@
], ],
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.0.tgz", "_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.0.tgz",
"_spec": "1.2.0", "_spec": "1.2.0",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"bugs": { "bugs": {
"url": "https://github.com/actions/toolkit/issues" "url": "https://github.com/actions/toolkit/issues"
}, },

View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"balanced-match@1.0.0", "balanced-match@1.0.0",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "balanced-match@1.0.0", "_from": "balanced-match@1.0.0",
@@ -26,7 +26,7 @@
], ],
"_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"_spec": "1.0.0", "_spec": "1.0.0",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"author": { "author": {
"name": "Julian Gruber", "name": "Julian Gruber",
"email": "mail@juliangruber.com", "email": "mail@juliangruber.com",

View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"brace-expansion@1.1.11", "brace-expansion@1.1.11",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "brace-expansion@1.1.11", "_from": "brace-expansion@1.1.11",
@@ -26,7 +26,7 @@
], ],
"_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"_spec": "1.1.11", "_spec": "1.1.11",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"author": { "author": {
"name": "Julian Gruber", "name": "Julian Gruber",
"email": "mail@juliangruber.com", "email": "mail@juliangruber.com",

View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"concat-map@0.0.1", "concat-map@0.0.1",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "concat-map@0.0.1", "_from": "concat-map@0.0.1",
@@ -26,7 +26,7 @@
], ],
"_resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "_resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"_spec": "0.0.1", "_spec": "0.0.1",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"author": { "author": {
"name": "James Halliday", "name": "James Halliday",
"email": "mail@substack.net", "email": "mail@substack.net",

View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"fs.realpath@1.0.0", "fs.realpath@1.0.0",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "fs.realpath@1.0.0", "_from": "fs.realpath@1.0.0",
@@ -27,7 +27,7 @@
], ],
"_resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "_resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"_spec": "1.0.0", "_spec": "1.0.0",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"author": { "author": {
"name": "Isaac Z. Schlueter", "name": "Isaac Z. Schlueter",
"email": "i@izs.me", "email": "i@izs.me",

4
node_modules/glob/package.json generated vendored
View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"glob@7.1.4", "glob@7.1.4",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "glob@7.1.4", "_from": "glob@7.1.4",
@@ -27,7 +27,7 @@
], ],
"_resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", "_resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz",
"_spec": "7.1.4", "_spec": "7.1.4",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"author": { "author": {
"name": "Isaac Z. Schlueter", "name": "Isaac Z. Schlueter",
"email": "i@izs.me", "email": "i@izs.me",

4
node_modules/inflight/package.json generated vendored
View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"inflight@1.0.6", "inflight@1.0.6",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "inflight@1.0.6", "_from": "inflight@1.0.6",
@@ -27,7 +27,7 @@
], ],
"_resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "_resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"_spec": "1.0.6", "_spec": "1.0.6",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"author": { "author": {
"name": "Isaac Z. Schlueter", "name": "Isaac Z. Schlueter",
"email": "i@izs.me", "email": "i@izs.me",

4
node_modules/inherits/package.json generated vendored
View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"inherits@2.0.4", "inherits@2.0.4",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "inherits@2.0.4", "_from": "inherits@2.0.4",
@@ -27,7 +27,7 @@
], ],
"_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"_spec": "2.0.4", "_spec": "2.0.4",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"browser": "./inherits_browser.js", "browser": "./inherits_browser.js",
"bugs": { "bugs": {
"url": "https://github.com/isaacs/inherits/issues" "url": "https://github.com/isaacs/inherits/issues"

View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"interpret@1.2.0", "interpret@1.2.0",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "interpret@1.2.0", "_from": "interpret@1.2.0",
@@ -26,7 +26,7 @@
], ],
"_resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz", "_resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz",
"_spec": "1.2.0", "_spec": "1.2.0",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"author": { "author": {
"name": "Gulp Team", "name": "Gulp Team",
"email": "team@gulpjs.com", "email": "team@gulpjs.com",

View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"minimatch@3.0.4", "minimatch@3.0.4",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "minimatch@3.0.4", "_from": "minimatch@3.0.4",
@@ -28,7 +28,7 @@
], ],
"_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"_spec": "3.0.4", "_spec": "3.0.4",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"author": { "author": {
"name": "Isaac Z. Schlueter", "name": "Isaac Z. Schlueter",
"email": "i@izs.me", "email": "i@izs.me",

4
node_modules/once/package.json generated vendored
View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"once@1.4.0", "once@1.4.0",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "once@1.4.0", "_from": "once@1.4.0",
@@ -28,7 +28,7 @@
], ],
"_resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "_resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"_spec": "1.4.0", "_spec": "1.4.0",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"author": { "author": {
"name": "Isaac Z. Schlueter", "name": "Isaac Z. Schlueter",
"email": "i@izs.me", "email": "i@izs.me",

View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"path-is-absolute@1.0.1", "path-is-absolute@1.0.1",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "path-is-absolute@1.0.1", "_from": "path-is-absolute@1.0.1",
@@ -27,7 +27,7 @@
], ],
"_resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "_resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"_spec": "1.0.1", "_spec": "1.0.1",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"author": { "author": {
"name": "Sindre Sorhus", "name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com", "email": "sindresorhus@gmail.com",

View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"path-parse@1.0.6", "path-parse@1.0.6",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "path-parse@1.0.6", "_from": "path-parse@1.0.6",
@@ -26,7 +26,7 @@
], ],
"_resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", "_resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
"_spec": "1.0.6", "_spec": "1.0.6",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"author": { "author": {
"name": "Javier Blanco", "name": "Javier Blanco",
"email": "http://jbgutierrez.info" "email": "http://jbgutierrez.info"

4
node_modules/rechoir/package.json generated vendored
View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"rechoir@0.6.2", "rechoir@0.6.2",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "rechoir@0.6.2", "_from": "rechoir@0.6.2",
@@ -26,7 +26,7 @@
], ],
"_resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", "_resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
"_spec": "0.6.2", "_spec": "0.6.2",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"author": { "author": {
"name": "Tyler Kellen", "name": "Tyler Kellen",
"url": "http://goingslowly.com/" "url": "http://goingslowly.com/"

4
node_modules/resolve/package.json generated vendored
View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"resolve@1.13.1", "resolve@1.13.1",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "resolve@1.13.1", "_from": "resolve@1.13.1",
@@ -27,7 +27,7 @@
], ],
"_resolved": "https://registry.npmjs.org/resolve/-/resolve-1.13.1.tgz", "_resolved": "https://registry.npmjs.org/resolve/-/resolve-1.13.1.tgz",
"_spec": "1.13.1", "_spec": "1.13.1",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"author": { "author": {
"name": "James Halliday", "name": "James Halliday",
"email": "mail@substack.net", "email": "mail@substack.net",

6
node_modules/shelljs/package.json generated vendored
View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"shelljs@0.8.3", "shelljs@0.8.3",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "shelljs@0.8.3", "_from": "shelljs@0.8.3",
@@ -26,13 +26,13 @@
], ],
"_resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.3.tgz", "_resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.3.tgz",
"_spec": "0.8.3", "_spec": "0.8.3",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"ava": { "ava": {
"serial": true, "serial": true,
"powerAssert": false "powerAssert": false
}, },
"bin": { "bin": {
"shjs": "bin/shjs" "shjs": "./bin/shjs"
}, },
"bugs": { "bugs": {
"url": "https://github.com/shelljs/shelljs/issues" "url": "https://github.com/shelljs/shelljs/issues"

4
node_modules/wrappy/package.json generated vendored
View File

@@ -2,7 +2,7 @@
"_args": [ "_args": [
[ [
"wrappy@1.0.2", "wrappy@1.0.2",
"C:\\GitHub\\add-and-commit" "C:\\EndBug\\GitHub\\add-and-commit"
] ]
], ],
"_from": "wrappy@1.0.2", "_from": "wrappy@1.0.2",
@@ -27,7 +27,7 @@
], ],
"_resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "_resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"_spec": "1.0.2", "_spec": "1.0.2",
"_where": "C:\\GitHub\\add-and-commit", "_where": "C:\\EndBug\\GitHub\\add-and-commit",
"author": { "author": {
"name": "Isaac Z. Schlueter", "name": "Isaac Z. Schlueter",
"email": "i@izs.me", "email": "i@izs.me",

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "add-and-commit", "name": "add-and-commit",
"version": "2.3.0", "version": "4.0.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "add-and-commit", "name": "add-and-commit",
"version": "2.3.0", "version": "4.0.0",
"description": "Add & commit files from a path directly from GitHub Actions", "description": "Add & commit files from a path directly from GitHub Actions",
"main": "lib/main.js", "main": "lib/main.js",
"scripts": { "scripts": {

View File

@@ -1,12 +1,12 @@
#!/bin/bash #!/bin/bash
set -eu set -u
cd $INPUT_CWD cd $INPUT_CWD
echo "Running in $PWD." echo "Running in $PWD."
# Set up .netrc file with GitHub credentials # Set up .netrc file with GitHub credentials
git_setup() { git_setup() {
cat <<- EOF > $HOME/.netrc cat <<-EOF >$HOME/.netrc
machine github.com machine github.com
login $GITHUB_ACTOR login $GITHUB_ACTOR
password $GITHUB_TOKEN password $GITHUB_TOKEN
@@ -16,33 +16,33 @@ git_setup() {
password $GITHUB_TOKEN password $GITHUB_TOKEN
EOF EOF
chmod 600 $HOME/.netrc chmod 600 $HOME/.netrc
git config --global user.email "$INPUT_AUTHOR_EMAIL" git config --global user.email "$INPUT_AUTHOR_EMAIL"
git config --global user.name "$INPUT_AUTHOR_NAME" git config --global user.name "$INPUT_AUTHOR_NAME"
} }
add() { add() {
if $INPUT_FORCE if $INPUT_FORCE; then f=-f; else f=; fi
then find $INPUT_PATH -name "$INPUT_PATTERN" | while read x; do git add -f $x; done git add $INPUT_ADD $f
else find $INPUT_PATH -name "$INPUT_PATTERN" | while read x; do git add $x; done }
fi
remove() {
if [ -n "$INPUT_REMOVE" ]; then git rm $INPUT_REMOVE; fi
} }
# This is needed to make the check work for untracked files # This is needed to make the check work for untracked files
echo "Staging files in commit path..." echo "Staging files..."
add add
remove
echo "Checking for uncommitted changes in the git working tree..." echo "Checking for uncommitted changes in the git working tree..."
# This section only runs if there have been file changes # This section only runs if there have been file changes
if ! git diff --cached --exit-code if ! git diff --cached --exit-code; then
then
git_setup git_setup
git fetch git fetch
# Verify if the branch needs to be created # Verify if the branch needs to be created
if ! git rev-parse --verify --quiet "${GITHUB_REF:11}" if ! git rev-parse --verify --quiet "${GITHUB_REF:11}"; then
then
echo "Creating branch..." echo "Creating branch..."
git branch "${GITHUB_REF:11}" git branch "${GITHUB_REF:11}"
fi fi
@@ -54,9 +54,15 @@ then
echo "Pulling from remote..." echo "Pulling from remote..."
git fetch && git pull git fetch && git pull
echo "Resetting files..."
git reset
echo "Adding files..." echo "Adding files..."
add add
echo "Removing files..."
remove
echo "Creating commit..." echo "Creating commit..."
git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>" git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>"

View File

@@ -5,20 +5,25 @@ import * as path from 'path'
try { try {
checkInputs() checkInputs()
shell.exec(path.join(__dirname, '../src/entrypoint.sh')) shell.exec(path.join(__dirname, '../src/entrypoint.sh'))
} catch (e) { } catch (err) {
core.setFailed(e) core.setFailed(err)
} }
function checkInputs() { function checkInputs() {
const eventPath = process.env.GITHUB_EVENT_PATH const eventPath = process.env.GITHUB_EVENT_PATH
if (eventPath) { if (eventPath) {
const { author } = require(eventPath).head_commit const { author } = require(eventPath).head_commit
if (!process.env.INPUT_AUTHOR_NAME) process.env.INPUT_AUTHOR_NAME = author.name setDefault('author_name', author.name)
if (!process.env.INPUT_AUTHOR_EMAIL) process.env.INPUT_AUTHOR_EMAIL = author.email setDefault('author_email', author.email)
} else { } else {
core.warning('No event path available, unable to fetch author info.') core.warning('No event path available, unable to fetch author info.')
if (!process.env.INPUT_AUTHOR_NAME) process.env.INPUT_AUTHOR_NAME = 'Add & Commit Action' setDefault('author_name', 'Add & Commit Action')
if (!process.env.INPUT_AUTHOR_EMAIL) process.env.INPUT_AUTHOR_EMAIL = 'actions@github.com' setDefault('author_email', 'actions@github.com')
} }
core.info(`Using '${process.env.INPUT_AUTHOR_NAME} <${process.env.INPUT_AUTHOR_EMAIL}>' as author.`) core.info(`Using '${core.getInput('author_name')} <${core.getInput('author_email')}>' as author.`)
}
function setDefault(input: string, value: string) {
const key = 'INPUT_' + input.toUpperCase()
if (!process.env[key]) process.env[key] = value
} }