-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# 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> | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-18-orange.svg?style=flat)](#contributors-) | ||
|
||
|
@@ -48,15 +49,15 @@ 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 | ||
signoff: true | ||
|
||
# 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 | ||
|
@@ -82,6 +83,16 @@ The script will not stop if one of the git commands fails. E.g.: if your command | |
|
||
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: | ||
|
@@ -90,34 +101,34 @@ Do you want to lint your JavaScript files, located in the `src` folder, with ESL | |
name: Lint source code | ||
on: push | ||
jobs: | ||
jobs: | ||
run: | ||
name: Lint with ESLint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12.x | ||
- name: Install dependencies | ||
run: npm install | ||
- name: Update source code | ||
run: eslint "src/**" --fix | ||
- name: Commit changes | ||
uses: EndBug/add-and-commit@v5 | ||
with: | ||
author_name: Your Name | ||
author_email: [email protected] | ||
message: "Your commit message" | ||
add: "*.js" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12.x | ||
- name: Install dependencies | ||
run: npm install | ||
- name: Update source code | ||
run: eslint "src/**" --fix | ||
- name: Commit changes | ||
uses: EndBug/add-and-commit@v5 | ||
with: | ||
author_name: Your Name | ||
author_email: [email protected] | ||
message: 'Your commit message' | ||
add: '*.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. | ||
|
@@ -126,7 +137,7 @@ If you need to run the action on a repository that is not located in [`$GITHUB_W | |
name: Use a different repository directory | ||
on: push | ||
jobs: | ||
jobs: | ||
run: | ||
name: Add a text file | ||
runs-on: ubuntu-latest | ||
|
@@ -135,17 +146,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 | ||
with: | ||
message: "Add the very useful text file" | ||
add: "*.txt --force" | ||
cwd: "./pathToRepo/" | ||
message: 'Add the very useful text file' | ||
add: '*.txt --force' | ||
cwd: './pathToRepo/' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
``` | ||
|
@@ -186,6 +197,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d | |
|
||
<!-- markdownlint-enable --> | ||
<!-- prettier-ignore-end --> | ||
|
||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
|
||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.