Allow to pass the commit message

This commit is contained in:
Carles Pina i Estany 2020-11-04 16:23:02 +00:00
parent 5a00473a58
commit cfb5cb5949
3 changed files with 15 additions and 1 deletions

View File

@ -30,6 +30,11 @@ The Username/Organization for the destination repository, if different from `des
### `target-branch` (argument) [optional]
The branch name for the destination repository, if different from `master`.
### `commit-message` (argument) [optional]
The commit message to be used in the output repository. Optional and defaults to "Update from $REPOSITORY_URL@commit".
The string `ORIGIN_COMMIT` is replaced by `$REPOSITORY_URL@commit`.
### `API_TOKEN_GITHUB` (environment)
E.g.:
`API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}`

View File

@ -21,6 +21,9 @@ inputs:
description: '[Optional] set target branch name for the destination repository. Defaults to "master"'
default: 'master'
required: false
commit-message: '[Optional] commit message for the output repository. ORIGIN_COMMIT is replaced by the URL@commit in the origin repo'
default: 'Update from ORIGIN_COMMIT'
required: false
runs:
using: 'docker'
image: 'Dockerfile'
@ -31,6 +34,7 @@ runs:
- ${{ inputs.user-email }}
- ${{ inputs.destination-repository-username }}
- ${{ inputs.target-branch }}
- ${{ inputs.commit-message }}
branding:
icon: 'git-commit'
color: 'green'

View File

@ -10,6 +10,7 @@ DESTINATION_REPOSITORY_NAME="$3"
USER_EMAIL="$4"
DESTINATION_REPOSITORY_USERNAME="$5"
TARGET_BRANCH="$6"
COMMIT_MESSAGE="$7"
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
then
@ -36,9 +37,13 @@ cd "$CLONE_DIR"
ls -la
echo "Adding git commit"
ORIGIN_COMMIT="https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
COMMIT_MESSAGE=$(echo "$COMMIT_MESSAGE" | sed "s/ORIGIN_COMMIT/$ORIGIN_COMMIT")
git add .
git status
git commit --message "Update from https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
git commit --message "$COMMIT_MESSAGE"
echo "Pushing git commit"
git push origin "$TARGET_BRANCH"