Merge pull request #7 from stefanzweifel/fix-branch-checkout

Bugfix: Fix git checkout and git push commands
This commit is contained in:
Stefan Zweifel 2019-09-20 19:50:49 +02:00 committed by GitHub
commit 8a0c95d76c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 5 deletions

View File

@ -18,6 +18,7 @@ Add the following step at the end of your job.
commit_author_email: john.doe@example.com
commit_author_name: John Doe
commit_message: Apply automatic changes
ref: ${{ github.head_ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
@ -32,6 +33,7 @@ The following inputs are required
- `commit_author_email`: The Commit Authors Email Address
- `commit_author_name`: The Commit Authors Name
- `commit_message`: The commit message used when changes are available
- `ref`: Branch where changes should be pushed too
### Environment Variables

View File

@ -5,13 +5,16 @@ author: Stefan Zweifel <hello@stefanzweifel.io>
inputs:
commit_message:
description: 'Commit message'
description: Commit message
required: true
commit_author_name:
description: 'Name of the commit author'
description: Name of the commit author
required: true
commit_author_email:
description: 'Email address of the commit author'
description: Email address of the commit author
required: true
ref:
description: Branch where changes should be pushed too
required: true
runs:

View File

@ -25,14 +25,16 @@ if ! git diff --quiet
then
git_setup
echo "INPUT_REF value: $INPUT_REF";
# Switch to branch from current Workflow run
git checkout "${GITHUB_REF:11}"
git checkout $INPUT_REF
git add .
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$INPUT_COMMIT_AUTHOR_NAME <$INPUT_COMMIT_AUTHOR_EMAIL>"
git push --set-upstream origin "${GITHUB_REF:11}"
git push --set-upstream origin "HEAD:$INPUT_REF"
else
echo "Working tree clean. Nothing to commit."
fi