-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from andstor/develop
v1.1.0
- Loading branch information
Showing
2 changed files
with
31 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -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}" | ||
|
||
|
@@ -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 👌" |