Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d926d1c554 | ||
|
|
8b797ba126 | ||
|
|
1b11953688 | ||
|
|
36bc3f778b | ||
|
|
c61b317dea | ||
|
|
22cdfa345a | ||
|
|
d4aeb9335d | ||
|
|
46569f991f | ||
|
|
83761c7e8e | ||
|
|
f0a1d2598a | ||
|
|
c902408157 | ||
|
|
6b705fa3a4 |
@@ -44,6 +44,10 @@ Add a step like this to your workflow:
|
||||
# Default: ''
|
||||
remove: "./dir/old_file.js"
|
||||
|
||||
# Name of the tag to add to the new commit (see the paragraph below for more info)
|
||||
# Default: ''
|
||||
tag: "v1.0.0"
|
||||
|
||||
env:
|
||||
# This is necessary in order to push a commit to the repo
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this line unchanged
|
||||
@@ -64,6 +68,11 @@ The script will not stop if one of the git commands fails. E.g.: if your command
|
||||
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 of 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.
|
||||
|
||||
### Tagging:
|
||||
|
||||
You can tag commits with the `tag` option: when used, it will create a lightweight tag for the commit with the name you set as input. If not entered (or if an empty string is passed) teh action won't create any tag.
|
||||
If there is already a tag with the name you entered it will be overwritten, and so the tag will be "updated".
|
||||
|
||||
### 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:
|
||||
|
||||
@@ -31,6 +31,10 @@ inputs:
|
||||
description: Arguments for the git rm command
|
||||
required: false
|
||||
default: ""
|
||||
tag:
|
||||
description: The name of the tag to add to the new commit
|
||||
required: false
|
||||
default: ""
|
||||
|
||||
runs:
|
||||
using: node12
|
||||
|
||||
@@ -31,6 +31,10 @@ remove() {
|
||||
if [ -n "$INPUT_REMOVE" ]; then git rm $INPUT_REMOVE; fi
|
||||
}
|
||||
|
||||
tag() {
|
||||
if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi
|
||||
}
|
||||
|
||||
# This is needed to make the check work for untracked files
|
||||
echo "Staging files..."
|
||||
add
|
||||
@@ -68,9 +72,15 @@ if ! git diff --cached --quiet --exit-code; then
|
||||
echo "Creating commit..."
|
||||
git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>"
|
||||
|
||||
echo "Pushing to repo..."
|
||||
echo "Tagging commit..."
|
||||
tag
|
||||
|
||||
echo "Pushing commits to repo..."
|
||||
git push --set-upstream origin "$INPUT_REF"
|
||||
|
||||
echo "Pushing tags to repo..."
|
||||
git push --set-upstream origin "$INPUT_REF" --force --tags
|
||||
|
||||
echo "::endgroup::"
|
||||
echo "Task completed."
|
||||
else
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "add-and-commit",
|
||||
"version": "4.1.0",
|
||||
"version": "4.2.0",
|
||||
"description": "Add & commit files from a path directly from GitHub Actions",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -31,6 +31,10 @@ remove() {
|
||||
if [ -n "$INPUT_REMOVE" ]; then git rm $INPUT_REMOVE; fi
|
||||
}
|
||||
|
||||
tag() {
|
||||
if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi
|
||||
}
|
||||
|
||||
# This is needed to make the check work for untracked files
|
||||
echo "Staging files..."
|
||||
add
|
||||
@@ -68,9 +72,15 @@ if ! git diff --cached --quiet --exit-code; then
|
||||
echo "Creating commit..."
|
||||
git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>"
|
||||
|
||||
echo "Pushing to repo..."
|
||||
echo "Tagging commit..."
|
||||
tag
|
||||
|
||||
echo "Pushing commits to repo..."
|
||||
git push --set-upstream origin "$INPUT_REF"
|
||||
|
||||
echo "Pushing tags to repo..."
|
||||
git push --set-upstream origin "$INPUT_REF" --force --tags
|
||||
|
||||
echo "::endgroup::"
|
||||
echo "Task completed."
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user