Skip to content

Commit

Permalink
Merge pull request #12 from andstor/develop
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
andstor authored Aug 29, 2019
2 parents d42a052 + 5e53ab0 commit 376b185
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
35 changes: 24 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,28 @@

## Usage
```
action "Copycat" {
uses = "andstor/[email protected]"
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/[email protected]
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: [email protected]
```

## Environment variables
Expand All @@ -29,6 +40,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).
Expand Down
12 changes: 7 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# @author André Storhaug <[email protected]>
# @date 2019-07-01
# @copyright MIT
# @version 0.1.2
# @version 1.2.0

set -o pipefail

Expand Down Expand Up @@ -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}"

Expand All @@ -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}"

Expand Down Expand Up @@ -82,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 👌"

0 comments on commit 376b185

Please sign in to comment.