Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e98be578d | ||
|
|
c07603c1c4 | ||
|
|
9cd6e9c0ea |
@@ -36,7 +36,11 @@ Add a step like this to your workflow:
|
||||
# Default: 'Commit from GitHub Actions'
|
||||
message: 'Your commit message'
|
||||
|
||||
# The arguments for the `git rm` command (see the paragraph below for more info)
|
||||
# Name of the branch to use, if different from the one that triggered the workflow
|
||||
# Default: the branch that triggered the workflow (from GITHUB_REF)
|
||||
ref: 'someOtherBranch'
|
||||
|
||||
# The arguments for the `git rm` command (see the paragraph below for more info)
|
||||
# Default: ''
|
||||
remove: "./dir/old_file.js"
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ inputs:
|
||||
description: The message for the commit
|
||||
required: false
|
||||
default: Commit from GitHub Actions
|
||||
ref:
|
||||
description: Name of the branch to use, if different from the one that triggered the workflow
|
||||
required: false
|
||||
remove:
|
||||
description: Arguments for the git rm command
|
||||
required: false
|
||||
|
||||
@@ -44,14 +44,14 @@ if ! git diff --cached --quiet --exit-code; then
|
||||
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 "$INPUT_REF"; then
|
||||
echo "Creating branch..."
|
||||
git branch "${GITHUB_REF:11}"
|
||||
git branch "$INPUT_REF"
|
||||
fi
|
||||
|
||||
# Switch to branch from current workflow run
|
||||
echo "Switching branch..."
|
||||
git checkout "${GITHUB_REF:11}"
|
||||
git checkout "$INPUT_REF"
|
||||
|
||||
echo "Pulling from remote..."
|
||||
git fetch && git pull
|
||||
@@ -69,7 +69,7 @@ if ! git diff --cached --quiet --exit-code; then
|
||||
git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>"
|
||||
|
||||
echo "Pushing to repo..."
|
||||
git push --set-upstream origin "${GITHUB_REF:11}"
|
||||
git push --set-upstream origin "$INPUT_REF"
|
||||
|
||||
echo "::endgroup::"
|
||||
echo "Task completed."
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "add-and-commit",
|
||||
"version": "4.0.3",
|
||||
"version": "4.1.0",
|
||||
"description": "Add & commit files from a path directly from GitHub Actions",
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -44,14 +44,14 @@ if ! git diff --cached --quiet --exit-code; then
|
||||
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 "$INPUT_REF"; then
|
||||
echo "Creating branch..."
|
||||
git branch "${GITHUB_REF:11}"
|
||||
git branch "$INPUT_REF"
|
||||
fi
|
||||
|
||||
# Switch to branch from current workflow run
|
||||
echo "Switching branch..."
|
||||
git checkout "${GITHUB_REF:11}"
|
||||
git checkout "$INPUT_REF"
|
||||
|
||||
echo "Pulling from remote..."
|
||||
git fetch && git pull
|
||||
@@ -69,7 +69,7 @@ if ! git diff --cached --quiet --exit-code; then
|
||||
git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>"
|
||||
|
||||
echo "Pushing to repo..."
|
||||
git push --set-upstream origin "${GITHUB_REF:11}"
|
||||
git push --set-upstream origin "$INPUT_REF"
|
||||
|
||||
echo "::endgroup::"
|
||||
echo "Task completed."
|
||||
|
||||
@@ -25,6 +25,8 @@ function checkInputs() {
|
||||
setDefault('author_email', 'actions@github.com')
|
||||
}
|
||||
|
||||
setDefault('ref', process.env.GITHUB_REF?.substring(11) || '')
|
||||
|
||||
info(`Using '${getInput('author_name')} <${getInput('author_email')}>' as author.`)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user