Compare commits

...

12 Commits

Author SHA1 Message Date
Federico Grandi
d926d1c554 [auto] Update compiled version 2020-05-17 16:26:50 +00:00
Federico Grandi
8b797ba126 Fix tag clobbering 2020-05-17 18:26:13 +02:00
Federico Grandi
1b11953688 Bump version: 4.2.0 2020-05-17 18:18:56 +02:00
Federico Grandi
36bc3f778b Improve tagging docs 2020-05-17 18:17:30 +02:00
Federico Grandi
c61b317dea Merge pull request #30 from ToMe25/master
Add tagging support
2020-05-17 18:12:19 +02:00
ToMe25
22cdfa345a [auto] Update compiled version 2020-05-16 17:54:55 +00:00
ToMe25
d4aeb9335d Hopefully this time fix which commit gets tagged 2020-05-16 19:54:18 +02:00
ToMe25
46569f991f [auto] Update compiled version 2020-05-16 17:45:45 +00:00
ToMe25
83761c7e8e Hopefully fix wrong commit getting tagged 2020-05-16 19:44:48 +02:00
ToMe25
f0a1d2598a [auto] Update compiled version 2020-05-16 17:17:36 +00:00
ToMe25
c902408157 Add missing push arg 2020-05-16 19:16:43 +02:00
ToMe25
6b705fa3a4 Add tagging support 2020-05-16 18:30:49 +02:00
5 changed files with 36 additions and 3 deletions

View File

@@ -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:

View File

@@ -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

View File

@@ -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

View File

@@ -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": {

View File

@@ -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