Extended functionality to additional repos

This commit is contained in:
Pau 2020-10-18 20:34:13 +02:00
parent 5d8dc0fe1a
commit 3f3ed70656
2 changed files with 20 additions and 12 deletions

View File

@ -1,34 +1,38 @@
name: 'Push directory to another repository'
description: 'Useful to push files to another repository to be used, for example, via github pages'
name: "Push directory to another repository"
description: "Useful to push files to another repository to be used, for example, via github pages"
inputs:
source-directory:
description: 'Source directory from the origin directory'
description: "Source directory from the origin directory"
required: true
additional-repos:
description: "Any additional repos for the final commit"
required: false
destination-github-username:
description: 'Name of the destination username/organization'
description: "Name of the destination username/organization"
required: true
destination-repository-name:
description: 'Destination repository'
description: "Destination repository"
required: true
user-email:
description: 'Email for the git commit'
description: "Email for the git commit"
required: true
destination-repository-username:
description: '[Optional] Username/organization for the destination repository'
description: "[Optional] Username/organization for the destination repository"
required: false
target-branch:
description: '[Optional] set target branch name for the destination repository'
description: "[Optional] set target branch name for the destination repository"
required: false
runs:
using: 'docker'
image: 'Dockerfile'
using: "docker"
image: "Dockerfile"
args:
- ${{ inputs.source-directory }}
- ${{ inputs.additional-repos }}
- ${{ inputs.destination-github-username }}
- ${{ inputs.destination-repository-name }}
- ${{ inputs.user-email }}
- ${{ inputs.destination-repository-username }}
- ${{ inputs.target-branch }}
branding:
icon: 'git-commit'
color: 'green'
icon: "git-commit"
color: "green"

View File

@ -7,6 +7,7 @@ GITHUB_REPO="$3"
USER_EMAIL="$4"
REPO_USERNAME="$5"
TARGET_BRANCH="$6"
ADDITIONAL_REPOS="$7"
if [ -z "$REPO_USERNAME" ]
then
@ -26,6 +27,9 @@ git config --global user.name "$GITHUB_USERNAME"
git clone --single-branch --branch "$TARGET_BRANCH" "https://$API_TOKEN_GITHUB@github.com/$REPO_USERNAME/$GITHUB_REPO.git" "$CLONE_DIR"
ls -la "$CLONE_DIR"
echo "Cloning additional repositories"
git clone --single-branch --branch "master" "https://$API_TOKEN_GITHUB@github.com/$REPO_USERNAME/$ADDITIONAL_REPOS.git" "$CLONE_DIR/projects"
echo "Cleaning destination repository of old files"
# Copy files into the git and deletes all git
find "$CLONE_DIR" | grep -v "^$CLONE_DIR/\.git" | grep -v "^$CLONE_DIR$" | xargs rm -rf # delete all files (to handle deletions)