Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a1f5ecb56 | ||
|
|
6d22917a33 | ||
|
|
cf96c454b6 |
25
README.md
25
README.md
@@ -11,7 +11,7 @@ Add a step like this to your workflow:
|
||||
|
||||
```yaml
|
||||
- name: Commit changes # This is the step name that will be displayed in your runs
|
||||
uses: EndBug/add-and-commit@v2.1.0 # You can change this to use a specific version
|
||||
uses: EndBug/add-and-commit@v2.1.1 # You can change this to use a specific version
|
||||
with: # See more info about inputs below
|
||||
author_name: Your Name
|
||||
author_email: mail@example.com
|
||||
@@ -37,6 +37,25 @@ Add a step like this to your workflow:
|
||||
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.
|
||||
|
||||
### 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:
|
||||
|
||||
```yaml
|
||||
- run: git rm delete_me.txt
|
||||
|
||||
- uses: EndBug/add-and-commit@v2.1.1
|
||||
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:
|
||||
@@ -65,7 +84,7 @@ jobs:
|
||||
run: eslint "src/**" --fix
|
||||
|
||||
- name: Commit changes
|
||||
uses: EndBug/add-and-commit@v2.1.0
|
||||
uses: EndBug/add-and-commit@v2.1.1
|
||||
with:
|
||||
author_name: Your Name
|
||||
author_email: mail@example.com
|
||||
@@ -78,4 +97,4 @@ jobs:
|
||||
|
||||
## License
|
||||
|
||||
This action is distributed under the MIT license, check the [license](LICENSE) for more info.
|
||||
This action is distributed under the MIT license, check the [license](LICENSE) for more info.
|
||||
|
||||
@@ -37,9 +37,15 @@ then
|
||||
|
||||
git fetch
|
||||
|
||||
# Switch to branch from current Workflow run
|
||||
echo "Creating and switching branch..."
|
||||
git branch "${GITHUB_REF:11}"
|
||||
# Verify if the branch needs to be created
|
||||
if ! git rev-parse --verify --quiet "${GITHUB_REF:11}"
|
||||
then
|
||||
echo "Creating branch..."
|
||||
git branch "${GITHUB_REF:11}"
|
||||
fi
|
||||
|
||||
# Switch to branch from current workflow run
|
||||
echo "Switching branch..."
|
||||
git checkout "${GITHUB_REF:11}"
|
||||
|
||||
echo "Adding files..."
|
||||
|
||||
Reference in New Issue
Block a user