mirror of
https://github.com/cpina/github-action-push-to-another-repository.git
synced 2024-12-22 08:06:10 -07:00
supports target branch for github-renaming
This commit is contained in:
parent
db81c54e24
commit
26fe0168e2
|
@ -25,6 +25,9 @@ The email that will be used for the commit in the destination-repository-name.
|
||||||
### `destination-repository-username` (argument) [optional]
|
### `destination-repository-username` (argument) [optional]
|
||||||
The Username/Organization for the destination repository, if different from `destination-github-username`. For the repository `https://github.com/cpina/push-to-another-repository-output` is `cpina`.
|
The Username/Organization for the destination repository, if different from `destination-github-username`. For the repository `https://github.com/cpina/push-to-another-repository-output` is `cpina`.
|
||||||
|
|
||||||
|
### `target-branch` (argument) [optional]
|
||||||
|
The branch name for the destination repository, if different from `master`.
|
||||||
|
|
||||||
### `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 }}`
|
||||||
|
|
|
@ -16,6 +16,9 @@ inputs:
|
||||||
destination-repository-username:
|
destination-repository-username:
|
||||||
description: '[Optional] Username/organization for the destination repository'
|
description: '[Optional] Username/organization for the destination repository'
|
||||||
required: false
|
required: false
|
||||||
|
target-branch:
|
||||||
|
description: '[Optional] set target branch name for the destination repository'
|
||||||
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
image: 'Dockerfile'
|
image: 'Dockerfile'
|
||||||
|
@ -25,6 +28,7 @@ runs:
|
||||||
- ${{ inputs.destination-repository-name }}
|
- ${{ inputs.destination-repository-name }}
|
||||||
- ${{ inputs.user-email }}
|
- ${{ inputs.user-email }}
|
||||||
- ${{ inputs.destination-repository-username }}
|
- ${{ inputs.destination-repository-username }}
|
||||||
|
- ${{ inputs.target-branch }}
|
||||||
branding:
|
branding:
|
||||||
icon: 'git-commit'
|
icon: 'git-commit'
|
||||||
color: 'green'
|
color: 'green'
|
||||||
|
|
|
@ -6,11 +6,16 @@ GITHUB_USERNAME="$2"
|
||||||
GITHUB_REPO="$3"
|
GITHUB_REPO="$3"
|
||||||
USER_EMAIL="$4"
|
USER_EMAIL="$4"
|
||||||
REPO_USERNAME="$5"
|
REPO_USERNAME="$5"
|
||||||
|
TARGET_BRANCH="$6"
|
||||||
|
|
||||||
if [ -z "$REPO_USERNAME" ]
|
if [ -z "$REPO_USERNAME" ]
|
||||||
then
|
then
|
||||||
REPO_USERNAME=$GITHUB_USERNAME
|
REPO_USERNAME=$GITHUB_USERNAME
|
||||||
fi
|
fi
|
||||||
|
if [ -z "$TARGET_BRANCH"]
|
||||||
|
then
|
||||||
|
TARGET_BRANCH="master"
|
||||||
|
fi
|
||||||
|
|
||||||
CLONE_DIR=$(mktemp -d)
|
CLONE_DIR=$(mktemp -d)
|
||||||
|
|
||||||
|
@ -18,7 +23,7 @@ echo "Cloning destination git repository"
|
||||||
# Setup git
|
# Setup git
|
||||||
git config --global user.email "$USER_EMAIL"
|
git config --global user.email "$USER_EMAIL"
|
||||||
git config --global user.name "$GITHUB_USERNAME"
|
git config --global user.name "$GITHUB_USERNAME"
|
||||||
git clone --single-branch --branch master "https://$API_TOKEN_GITHUB@github.com/$REPO_USERNAME/$GITHUB_REPO.git" "$CLONE_DIR"
|
git clone --single-branch --branch $TARGET_BRANCH "https://$API_TOKEN_GITHUB@github.com/$REPO_USERNAME/$GITHUB_REPO.git" "$CLONE_DIR"
|
||||||
ls -la "$CLONE_DIR"
|
ls -la "$CLONE_DIR"
|
||||||
|
|
||||||
echo "Cleaning destination repository of old files"
|
echo "Cleaning destination repository of old files"
|
||||||
|
@ -37,4 +42,4 @@ git status
|
||||||
git commit --message "Update from https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
|
git commit --message "Update from https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
|
||||||
|
|
||||||
echo "Pushing git commit"
|
echo "Pushing git commit"
|
||||||
git push origin master
|
git push origin $TARGET_BRANCH
|
||||||
|
|
Loading…
Reference in New Issue
Block a user