mirror of
https://github.com/cpina/github-action-push-to-another-repository.git
synced 2025-09-05 08:05:47 -06:00
Added Source File and Target File Feature
This commit is contained in:
parent
7c1bd869f3
commit
6c4b6891cf
10
action.yml
10
action.yml
@ -54,6 +54,14 @@ inputs:
|
|||||||
[Optional] create target branch if not exist. Defaults to `false`
|
[Optional] create target branch if not exist. Defaults to `false`
|
||||||
default: false
|
default: false
|
||||||
required: false
|
required: false
|
||||||
|
source-file:
|
||||||
|
description: '[Optional] Source file to transfer'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
target-file:
|
||||||
|
description: '[Optional] Target file path in destination repository'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: docker
|
using: docker
|
||||||
@ -71,6 +79,8 @@ runs:
|
|||||||
- '${{ inputs.commit-message }}'
|
- '${{ inputs.commit-message }}'
|
||||||
- '${{ inputs.target-directory }}'
|
- '${{ inputs.target-directory }}'
|
||||||
- '${{ inputs.create-target-branch-if-needed }}'
|
- '${{ inputs.create-target-branch-if-needed }}'
|
||||||
|
- '${{ inputs.source-file }}'
|
||||||
|
- '${{ inputs.target-file }}'
|
||||||
branding:
|
branding:
|
||||||
icon: git-commit
|
icon: git-commit
|
||||||
color: green
|
color: green
|
||||||
|
@ -16,6 +16,8 @@ TARGET_BRANCH="${9}"
|
|||||||
COMMIT_MESSAGE="${10}"
|
COMMIT_MESSAGE="${10}"
|
||||||
TARGET_DIRECTORY="${11}"
|
TARGET_DIRECTORY="${11}"
|
||||||
CREATE_TARGET_BRANCH_IF_NEEDED="${12}"
|
CREATE_TARGET_BRANCH_IF_NEEDED="${12}"
|
||||||
|
SOURCE_FILE="${13}"
|
||||||
|
TARGET_FILE="${14}"
|
||||||
|
|
||||||
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
|
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
|
||||||
then
|
then
|
||||||
@ -117,6 +119,9 @@ ls -al /
|
|||||||
|
|
||||||
mv "$TEMP_DIR/.git" "$CLONE_DIR/.git"
|
mv "$TEMP_DIR/.git" "$CLONE_DIR/.git"
|
||||||
|
|
||||||
|
# if source directory is set
|
||||||
|
if [ -n "$SOURCE_DIRECTORY" ]
|
||||||
|
then
|
||||||
echo "[+] List contents of $SOURCE_DIRECTORY"
|
echo "[+] List contents of $SOURCE_DIRECTORY"
|
||||||
ls "$SOURCE_DIRECTORY"
|
ls "$SOURCE_DIRECTORY"
|
||||||
|
|
||||||
@ -137,6 +142,30 @@ fi
|
|||||||
|
|
||||||
echo "[+] Copying contents of source repository folder $SOURCE_DIRECTORY to folder $TARGET_DIRECTORY in git repo $DESTINATION_REPOSITORY_NAME"
|
echo "[+] Copying contents of source repository folder $SOURCE_DIRECTORY to folder $TARGET_DIRECTORY in git repo $DESTINATION_REPOSITORY_NAME"
|
||||||
cp -ra "$SOURCE_DIRECTORY"/. "$CLONE_DIR/$TARGET_DIRECTORY"
|
cp -ra "$SOURCE_DIRECTORY"/. "$CLONE_DIR/$TARGET_DIRECTORY"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$SOURCE_FILE" ] && [ -n "$TARGET_FILE" ]
|
||||||
|
then
|
||||||
|
echo "[+] SOURCE_FILE: $SOURCE_FILE"
|
||||||
|
echo "[+] TARGET_FILE: $TARGET_FILE"
|
||||||
|
|
||||||
|
echo "[+] Copying single file from $SOURCE_FILE to $TARGET_FILE"
|
||||||
|
if [ ! -f "$SOURCE_FILE" ]
|
||||||
|
then
|
||||||
|
echo "::error::Source file $SOURCE_FILE does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create target directory if it doesn't exist
|
||||||
|
TARGET_FILE_DIR=$(dirname "$CLONE_DIR/$TARGET_FILE")
|
||||||
|
mkdir -p "$TARGET_FILE_DIR"
|
||||||
|
|
||||||
|
# Copy the file
|
||||||
|
cp "$SOURCE_FILE" "$CLONE_DIR/$TARGET_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cd "$CLONE_DIR"
|
cd "$CLONE_DIR"
|
||||||
|
|
||||||
echo "[+] Files that will be pushed"
|
echo "[+] Files that will be pushed"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user