From eee6725ff5578973bb0d4cbc956cabe4ea98dae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Storhaug?= Date: Mon, 26 Aug 2019 22:15:54 +0200 Subject: [PATCH 1/3] Make username and email configurable Fixes #11 --- README.md | 2 ++ entrypoint.sh | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 87393d1..4e7805f 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ The following environment variable options can/must be configured: |`DST_BRANCH`|Optional|The branch name of the destination repository. Optional.|`master`| |`SRC_WIKI`|Optional|Set to `true` if the source repository you want to copy from is the GitHub Wiki.| `false`| |`DST_WIKI`|Optional|Set to `true` if the destination repository you want to copy from is the GitHub Wiki.|`false`| +|`USERNAME`|Optional|The GitHub username to associate commits made by this GitHub action.|[`GITHUB_ACTOR`](https://help.github.com/en/articles/virtual-environments-for-github-actions#environment-variables)| +|`EMAIL`|Optional|The email used for associating commits made by this GitHub action.|[`GITHUB_ACTOR`](https://help.github.com/en/articles/virtual-environments-for-github-actions#environment-variables)`@users.noreply.github.com`| ## Secrets * `GH_PAT`: (required) GitHub Private Access Token used for the clone/push operations. To create it follow the [GitHub Documentation](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line). diff --git a/entrypoint.sh b/entrypoint.sh index 983c278..90b4a84 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -37,6 +37,9 @@ fi BASE_PATH=$(pwd) DST_PATH="${DST_PATH:-${SRC_PATH}}" +USERNAME="${USERNAME:-${GITHUB_ACTOR}}" +EMAIL="${EMAIL:-${GITHUB_ACTOR}@users.noreply.github.com}" + SRC_BRANCH="${SRC_BRANCH:-master}" DST_BRANCH="${DST_BRANCH:-master}" @@ -47,8 +50,8 @@ DST_REPO_NAME="${DST_REPO_NAME}${DST_WIKI}" DIR="${DST_PATH%/*}" -git config --global user.name "${GITHUB_ACTOR}" -git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" +git config --global user.name "${USERNAME}" +git config --global user.email "${EMAIL}" echo "Copying \"${SRC_REPO_NAME}/${SRC_PATH}\" and pushing it to ${GITHUB_REPOSITORY}" From 958db5964d61e8b2265b9884cf7c8f80818b6184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Storhaug?= Date: Thu, 29 Aug 2019 15:00:37 +0200 Subject: [PATCH 2/3] Update README.md file --- README.md | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 4e7805f..b4bbc80 100644 --- a/README.md +++ b/README.md @@ -3,17 +3,28 @@ ## Usage ``` -action "Copycat" { - uses = "andstor/copycat-action@v1.0.1" - secrets = ["GH_PAT"] - env = { - DST_OWNER = "andstor" - DST_REPO_NAME = "copycat-action" - SRC_WIKI = "true" - DST_PATH = "/wiki/" - SRC_PATH = "/." - } -} +name: Copy +on: gollum +jobs: + copycat: + name: Copycat + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Copycat + uses: andstor/copycat-action@v1.1.0 + env: + DST_BRANCH: master + DST_OWNER: andstor + DST_REPO_NAME: copycat-action + DST_PATH: /wiki/ + GH_PAT: ${{ secrets.GH_PAT }} + SRC_BRANCH: master + SRC_PATH: /. + SRC_WIKI: "true" + USERNAME: nutsbot + EMAIL: andr3.storhaug+bot@gmail.com + ``` ## Environment variables From 5e53ab0cb36ee34a376b1ef0ec1294060aa2d0af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Storhaug?= Date: Thu, 29 Aug 2019 15:09:22 +0200 Subject: [PATCH 3/3] Remove set upstream command --- entrypoint.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 90b4a84..461ba65 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,7 +3,7 @@ # @author André Storhaug # @date 2019-07-01 # @copyright MIT -# @version 0.1.2 +# @version 1.2.0 set -o pipefail @@ -85,8 +85,7 @@ else # Uncommitted changes git add -A git commit --message "${COMMIT_MESSAGE}" - - git push -u origin ${DST_BRANCH} + git push origin ${DST_BRANCH} fi echo "Copying complete 👌" \ No newline at end of file