mirror of
https://github.com/cpina/github-action-push-to-another-repository.git
synced 2024-12-22 08:06:10 -07:00
Allow to pass the commit message
This commit is contained in:
parent
5a00473a58
commit
cfb5cb5949
|
@ -30,6 +30,11 @@ The Username/Organization for the destination repository, if different from `des
|
||||||
### `target-branch` (argument) [optional]
|
### `target-branch` (argument) [optional]
|
||||||
The branch name for the destination repository, if different from `master`.
|
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)
|
### `API_TOKEN_GITHUB` (environment)
|
||||||
E.g.:
|
E.g.:
|
||||||
`API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}`
|
`API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}`
|
||||||
|
|
|
@ -21,6 +21,9 @@ inputs:
|
||||||
description: '[Optional] set target branch name for the destination repository. Defaults to "master"'
|
description: '[Optional] set target branch name for the destination repository. Defaults to "master"'
|
||||||
default: 'master'
|
default: 'master'
|
||||||
required: false
|
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:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
image: 'Dockerfile'
|
image: 'Dockerfile'
|
||||||
|
@ -31,6 +34,7 @@ runs:
|
||||||
- ${{ inputs.user-email }}
|
- ${{ inputs.user-email }}
|
||||||
- ${{ inputs.destination-repository-username }}
|
- ${{ inputs.destination-repository-username }}
|
||||||
- ${{ inputs.target-branch }}
|
- ${{ inputs.target-branch }}
|
||||||
|
- ${{ inputs.commit-message }}
|
||||||
branding:
|
branding:
|
||||||
icon: 'git-commit'
|
icon: 'git-commit'
|
||||||
color: 'green'
|
color: 'green'
|
||||||
|
|
|
@ -10,6 +10,7 @@ DESTINATION_REPOSITORY_NAME="$3"
|
||||||
USER_EMAIL="$4"
|
USER_EMAIL="$4"
|
||||||
DESTINATION_REPOSITORY_USERNAME="$5"
|
DESTINATION_REPOSITORY_USERNAME="$5"
|
||||||
TARGET_BRANCH="$6"
|
TARGET_BRANCH="$6"
|
||||||
|
COMMIT_MESSAGE="$7"
|
||||||
|
|
||||||
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
|
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
|
||||||
then
|
then
|
||||||
|
@ -36,9 +37,13 @@ cd "$CLONE_DIR"
|
||||||
ls -la
|
ls -la
|
||||||
|
|
||||||
echo "Adding git commit"
|
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 add .
|
||||||
git status
|
git status
|
||||||
git commit --message "Update from https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
|
git commit --message "$COMMIT_MESSAGE"
|
||||||
|
|
||||||
echo "Pushing git commit"
|
echo "Pushing git commit"
|
||||||
git push origin "$TARGET_BRANCH"
|
git push origin "$TARGET_BRANCH"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user