Add ref option

This commit is contained in:
Federico Grandi
2020-05-01 15:27:44 +02:00
parent 5bf921b386
commit 9cd6e9c0ea
4 changed files with 14 additions and 5 deletions

View File

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

View File

@@ -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.`)
}