Updates and avoids having the email hardcoded

This commit is contained in:
cpina 2020-03-29 17:20:35 +02:00
parent 38563e1748
commit 0f0c204dae
2 changed files with 8 additions and 15 deletions

View File

@ -10,6 +10,9 @@ inputs:
destination-repository-name: destination-repository-name:
description: 'Destination repository' description: 'Destination repository'
required: true required: true
user-email:
description: 'Email for the git commit'
required: true
runs: runs:
using: 'docker' using: 'docker'
image: 'Dockerfile' image: 'Dockerfile'
@ -17,3 +20,4 @@ runs:
- ${{ inputs.source-directory }} - ${{ inputs.source-directory }}
- ${{ inputs.destination-github-username }} - ${{ inputs.destination-github-username }}
- ${{ inputs.destination-repository-name }} - ${{ inputs.destination-repository-name }}
- ${{ inputs.git-user-email }}

View File

@ -4,32 +4,21 @@ echo "Starts"
FOLDER="$1" FOLDER="$1"
GITHUB_USERNAME="$2" GITHUB_USERNAME="$2"
GITHUB_REPO="$3" GITHUB_REPO="$3"
GIT_USER_EMAIL="$4"
CLONE_DIR="clone_repo" CLONE_DIR="clone_repo"
git config --global user.email "carles@pina.cat" # Setup git
git config --global user.email "$GIT_USER_EMAIL"
git config --global user.name "$GITHUB_USERNAME" git config --global user.name "$GITHUB_USERNAME"
git clone "https://$API_TOKEN_GITHUB@github.com/$GITHUB_USERNAME/$GITHUB_REPO.git" "$CLONE_DIR" git clone "https://$API_TOKEN_GITHUB@github.com/$GITHUB_USERNAME/$GITHUB_REPO.git" "$CLONE_DIR"
ls -l # Copy files into the git and deletes all git
cd "$CLONE_DIR" cd "$CLONE_DIR"
# find needs to be in the git repository directory # find needs to be in the git repository directory
find . | grep -v ".git" | grep -v "^\.*$" | xargs rm -rf # delete all files (to handle deletions) find . | grep -v ".git" | grep -v "^\.*$" | xargs rm -rf # delete all files (to handle deletions)
cp -r "../$FOLDER"/* . cp -r "../$FOLDER"/* .
echo "After cd $CLONE_DIR"
ls -la
git add . git add .
git commit --message "Update from $GITHUB_REPOSITORY" git commit --message "Update from $GITHUB_REPOSITORY"
git push origin master git push origin master
cd ..
echo "Done!"
echo "Ends"