Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff8ca18c9f |
10
.github/workflows/build.yml
vendored
10
.github/workflows/build.yml
vendored
@@ -3,8 +3,6 @@ on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- dist
|
||||
paths:
|
||||
- src/**
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -12,12 +10,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v1
|
||||
uses: actions/setup-node@master
|
||||
with:
|
||||
node-version: 12.x
|
||||
node-version: 12.0.0
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
@@ -26,7 +24,7 @@ jobs:
|
||||
run: npm run build
|
||||
|
||||
- name: Commit changes
|
||||
uses: EndBug/add-and-commit@v2
|
||||
uses: EndBug/add-and-commit@v2.3.0
|
||||
with:
|
||||
force: true
|
||||
message: "[auto] Update compiled version"
|
||||
|
||||
2
.github/workflows/versioning.yml
vendored
2
.github/workflows/versioning.yml
vendored
@@ -2,7 +2,7 @@ name: Keep the versions up-to-date
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published, edited]
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
actions-tagger:
|
||||
|
||||
110
README.md
110
README.md
@@ -10,59 +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:
|
||||
|
||||
```yaml
|
||||
- uses: EndBug/add-and-commit@v4 # 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: '.'
|
||||
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
|
||||
- name: Commit changes # This is the step name that will be displayed in your runs
|
||||
uses: EndBug/add-and-commit@v2 # You can change this to use a specific version
|
||||
with: # See more info about inputs below
|
||||
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
|
||||
|
||||
# The local path to the directory where your repository is located. You should use actions/checkout first to set it up
|
||||
# Default: '.'
|
||||
cwd: './path/to/the/repo'
|
||||
|
||||
# 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"
|
||||
|
||||
message: "Your commit message"
|
||||
path: "."
|
||||
pattern: "*.js"
|
||||
force: false
|
||||
env:
|
||||
# This is necessary in order to push a commit to the repo
|
||||
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
|
||||
- `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:
|
||||
|
||||
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.
|
||||
|
||||
### 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:
|
||||
|
||||
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.
|
||||
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:
|
||||
|
||||
### Examples:
|
||||
```yaml
|
||||
- run: git rm delete_me.txt
|
||||
|
||||
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:
|
||||
- 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 }}
|
||||
```
|
||||
|
||||
### Example:
|
||||
|
||||
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:
|
||||
|
||||
```yaml
|
||||
name: Lint source code
|
||||
@@ -74,7 +70,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v1
|
||||
@@ -88,47 +84,17 @@ jobs:
|
||||
run: eslint "src/**" --fix
|
||||
|
||||
- name: Commit changes
|
||||
uses: EndBug/add-and-commit@v4
|
||||
uses: EndBug/add-and-commit@v2
|
||||
with:
|
||||
author_name: Your Name
|
||||
author_email: mail@example.com
|
||||
message: "Your commit message"
|
||||
add: "*.js"
|
||||
path: "."
|
||||
pattern: "*.js"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
```yaml
|
||||
name: Use a different repository directory
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
run:
|
||||
name: Add a text file
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# If you need to, you can checkout your repo to a different location
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
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@v4
|
||||
with:
|
||||
message: "Add the very useful text file"
|
||||
add: "*.txt"
|
||||
cwd: "./pathToRepo/"
|
||||
force: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This action is distributed under the MIT license, check the [license](LICENSE) for more info.
|
||||
|
||||
18
action.yml
18
action.yml
@@ -2,20 +2,12 @@ name: Add & Commit
|
||||
description: Add & commit files from a path directly from GitHub Actions
|
||||
|
||||
inputs:
|
||||
add:
|
||||
description: Arguments for the git add command
|
||||
required: false
|
||||
default: "."
|
||||
author_name:
|
||||
description: The name of the user that will be displayed as the author of the commit
|
||||
required: false
|
||||
author_email:
|
||||
description: The email of the user that will be displayed as the author of the commit
|
||||
required: false
|
||||
cwd:
|
||||
description: The directory where your repository is located. You should use actions/checkout first to set it up
|
||||
required: false
|
||||
default: "."
|
||||
force:
|
||||
description: Whether to use the force option on git add, in order to bypass eventual gitignores
|
||||
required: false
|
||||
@@ -24,10 +16,14 @@ inputs:
|
||||
description: The message for the commit
|
||||
required: false
|
||||
default: Commit from GitHub Actions
|
||||
remove:
|
||||
description: Arguments for the git rm command
|
||||
path:
|
||||
description: The path to stage files from
|
||||
required: false
|
||||
default: ""
|
||||
default: "."
|
||||
pattern:
|
||||
description: The pattern that mathces file names
|
||||
required: false
|
||||
default: "*.*"
|
||||
|
||||
runs:
|
||||
using: node12
|
||||
|
||||
@@ -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;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)}
|
||||
"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.`)}
|
||||
4
node_modules/@actions/core/package.json
generated
vendored
4
node_modules/@actions/core/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"@actions/core@1.2.0",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "@actions/core@1.2.0",
|
||||
@@ -27,7 +27,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.0.tgz",
|
||||
"_spec": "1.2.0",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"bugs": {
|
||||
"url": "https://github.com/actions/toolkit/issues"
|
||||
},
|
||||
|
||||
4
node_modules/balanced-match/package.json
generated
vendored
4
node_modules/balanced-match/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"balanced-match@1.0.0",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "balanced-match@1.0.0",
|
||||
@@ -26,7 +26,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"_spec": "1.0.0",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
|
||||
4
node_modules/brace-expansion/package.json
generated
vendored
4
node_modules/brace-expansion/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"brace-expansion@1.1.11",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "brace-expansion@1.1.11",
|
||||
@@ -26,7 +26,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"_spec": "1.1.11",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
|
||||
4
node_modules/concat-map/package.json
generated
vendored
4
node_modules/concat-map/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"concat-map@0.0.1",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "concat-map@0.0.1",
|
||||
@@ -26,7 +26,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"_spec": "0.0.1",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
|
||||
4
node_modules/fs.realpath/package.json
generated
vendored
4
node_modules/fs.realpath/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"fs.realpath@1.0.0",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "fs.realpath@1.0.0",
|
||||
@@ -27,7 +27,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"_spec": "1.0.0",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
|
||||
4
node_modules/glob/package.json
generated
vendored
4
node_modules/glob/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"glob@7.1.4",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "glob@7.1.4",
|
||||
@@ -27,7 +27,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz",
|
||||
"_spec": "7.1.4",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
|
||||
4
node_modules/inflight/package.json
generated
vendored
4
node_modules/inflight/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"inflight@1.0.6",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "inflight@1.0.6",
|
||||
@@ -27,7 +27,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"_spec": "1.0.6",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
|
||||
4
node_modules/inherits/package.json
generated
vendored
4
node_modules/inherits/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"inherits@2.0.4",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "inherits@2.0.4",
|
||||
@@ -27,7 +27,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"_spec": "2.0.4",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"browser": "./inherits_browser.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/inherits/issues"
|
||||
|
||||
4
node_modules/interpret/package.json
generated
vendored
4
node_modules/interpret/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"interpret@1.2.0",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "interpret@1.2.0",
|
||||
@@ -26,7 +26,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz",
|
||||
"_spec": "1.2.0",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"author": {
|
||||
"name": "Gulp Team",
|
||||
"email": "team@gulpjs.com",
|
||||
|
||||
4
node_modules/minimatch/package.json
generated
vendored
4
node_modules/minimatch/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"minimatch@3.0.4",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "minimatch@3.0.4",
|
||||
@@ -28,7 +28,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"_spec": "3.0.4",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
|
||||
4
node_modules/once/package.json
generated
vendored
4
node_modules/once/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"once@1.4.0",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "once@1.4.0",
|
||||
@@ -28,7 +28,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"_spec": "1.4.0",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
|
||||
4
node_modules/path-is-absolute/package.json
generated
vendored
4
node_modules/path-is-absolute/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"path-is-absolute@1.0.1",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_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",
|
||||
"_spec": "1.0.1",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
|
||||
4
node_modules/path-parse/package.json
generated
vendored
4
node_modules/path-parse/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"path-parse@1.0.6",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "path-parse@1.0.6",
|
||||
@@ -26,7 +26,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
|
||||
"_spec": "1.0.6",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"author": {
|
||||
"name": "Javier Blanco",
|
||||
"email": "http://jbgutierrez.info"
|
||||
|
||||
4
node_modules/rechoir/package.json
generated
vendored
4
node_modules/rechoir/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"rechoir@0.6.2",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "rechoir@0.6.2",
|
||||
@@ -26,7 +26,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
|
||||
"_spec": "0.6.2",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"author": {
|
||||
"name": "Tyler Kellen",
|
||||
"url": "http://goingslowly.com/"
|
||||
|
||||
4
node_modules/resolve/package.json
generated
vendored
4
node_modules/resolve/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"resolve@1.13.1",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "resolve@1.13.1",
|
||||
@@ -27,7 +27,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/resolve/-/resolve-1.13.1.tgz",
|
||||
"_spec": "1.13.1",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
|
||||
4
node_modules/shelljs/package.json
generated
vendored
4
node_modules/shelljs/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"shelljs@0.8.3",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "shelljs@0.8.3",
|
||||
@@ -26,7 +26,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.3.tgz",
|
||||
"_spec": "0.8.3",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"ava": {
|
||||
"serial": true,
|
||||
"powerAssert": false
|
||||
|
||||
4
node_modules/wrappy/package.json
generated
vendored
4
node_modules/wrappy/package.json
generated
vendored
@@ -2,7 +2,7 @@
|
||||
"_args": [
|
||||
[
|
||||
"wrappy@1.0.2",
|
||||
"C:\\EndBug\\GitHub\\add-and-commit"
|
||||
"c:\\EndBug\\GitHub\\add-and-commit"
|
||||
]
|
||||
],
|
||||
"_from": "wrappy@1.0.2",
|
||||
@@ -27,7 +27,7 @@
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"_spec": "1.0.2",
|
||||
"_where": "C:\\EndBug\\GitHub\\add-and-commit",
|
||||
"_where": "c:\\EndBug\\GitHub\\add-and-commit",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "add-and-commit",
|
||||
"version": "4.0.0",
|
||||
"version": "2.3.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "add-and-commit",
|
||||
"version": "4.0.0",
|
||||
"version": "2.3.0",
|
||||
"description": "Add & commit files from a path directly from GitHub Actions",
|
||||
"main": "lib/main.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
#!/bin/bash
|
||||
set -u
|
||||
|
||||
cd $INPUT_CWD
|
||||
echo "Running in $PWD."
|
||||
set -eu
|
||||
|
||||
# Set up .netrc file with GitHub credentials
|
||||
git_setup() {
|
||||
cat <<-EOF >$HOME/.netrc
|
||||
cat <<- EOF > $HOME/.netrc
|
||||
machine github.com
|
||||
login $GITHUB_ACTOR
|
||||
password $GITHUB_TOKEN
|
||||
@@ -16,33 +13,33 @@ git_setup() {
|
||||
password $GITHUB_TOKEN
|
||||
EOF
|
||||
chmod 600 $HOME/.netrc
|
||||
|
||||
git config --global user.email "$INPUT_AUTHOR_EMAIL"
|
||||
git config --global user.name "$INPUT_AUTHOR_NAME"
|
||||
}
|
||||
|
||||
add() {
|
||||
if $INPUT_FORCE; then f=-f; else f=; fi
|
||||
git add $INPUT_ADD $f
|
||||
}
|
||||
|
||||
remove() {
|
||||
if [ -n "$INPUT_REMOVE" ]; then git rm $INPUT_REMOVE; fi
|
||||
if $INPUT_FORCE
|
||||
then find $INPUT_PATH -name "$INPUT_PATTERN" | while read x; do git add -f $x; done
|
||||
else find $INPUT_PATH -name "$INPUT_PATTERN" | while read x; do git add $x; done
|
||||
fi
|
||||
}
|
||||
|
||||
# This is needed to make the check work for untracked files
|
||||
echo "Staging files..."
|
||||
echo "Staging files in commit path..."
|
||||
add
|
||||
remove
|
||||
|
||||
echo "Checking for uncommitted changes in the git working tree..."
|
||||
# This section only runs if there have been file changes
|
||||
if ! git diff --cached --exit-code; then
|
||||
if ! git diff --cached --exit-code
|
||||
then
|
||||
git_setup
|
||||
|
||||
git fetch
|
||||
git fetch
|
||||
|
||||
# Verify if the branch needs to be created
|
||||
if ! git rev-parse --verify --quiet "${GITHUB_REF:11}"; then
|
||||
if ! git rev-parse --verify --quiet "${GITHUB_REF:11}"
|
||||
then
|
||||
echo "Creating branch..."
|
||||
git branch "${GITHUB_REF:11}"
|
||||
fi
|
||||
@@ -51,18 +48,9 @@ if ! git diff --cached --exit-code; then
|
||||
echo "Switching branch..."
|
||||
git checkout "${GITHUB_REF:11}"
|
||||
|
||||
echo "Pulling from remote..."
|
||||
git fetch && git pull
|
||||
|
||||
echo "Resetting files..."
|
||||
git reset
|
||||
|
||||
echo "Adding files..."
|
||||
add
|
||||
|
||||
echo "Removing files..."
|
||||
remove
|
||||
|
||||
echo "Creating commit..."
|
||||
git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>"
|
||||
|
||||
|
||||
19
src/main.ts
19
src/main.ts
@@ -5,25 +5,20 @@ import * as path from 'path'
|
||||
try {
|
||||
checkInputs()
|
||||
shell.exec(path.join(__dirname, '../src/entrypoint.sh'))
|
||||
} catch (err) {
|
||||
core.setFailed(err)
|
||||
} catch (e) {
|
||||
core.setFailed(e)
|
||||
}
|
||||
|
||||
function checkInputs() {
|
||||
const eventPath = process.env.GITHUB_EVENT_PATH
|
||||
if (eventPath) {
|
||||
const { author } = require(eventPath).head_commit
|
||||
setDefault('author_name', author.name)
|
||||
setDefault('author_email', author.email)
|
||||
if (!process.env.INPUT_AUTHOR_NAME) process.env.INPUT_AUTHOR_NAME = author.name
|
||||
if (!process.env.INPUT_AUTHOR_EMAIL) process.env.INPUT_AUTHOR_EMAIL = author.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')
|
||||
if (!process.env.INPUT_AUTHOR_NAME) process.env.INPUT_AUTHOR_NAME = 'Add & Commit Action'
|
||||
if (!process.env.INPUT_AUTHOR_EMAIL) process.env.INPUT_AUTHOR_EMAIL = 'actions@github.com'
|
||||
}
|
||||
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
|
||||
core.info(`Using '${process.env.INPUT_AUTHOR_NAME} <${process.env.INPUT_AUTHOR_EMAIL}>' as author.`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user