From 3f3ed70656dee55d20c4f8b536c7805f95165e8e Mon Sep 17 00:00:00 2001 From: Pau Date: Sun, 18 Oct 2020 20:34:13 +0200 Subject: [PATCH] Extended functionality to additional repos --- action.yml | 28 ++++++++++++++++------------ entrypoint.sh | 4 ++++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/action.yml b/action.yml index b3e65ef..b0669b8 100644 --- a/action.yml +++ b/action.yml @@ -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" diff --git a/entrypoint.sh b/entrypoint.sh index ea93e63..8a5dc3f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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)