diff --git a/CHANGELOG.md b/CHANGELOG.md index d1be0ee..7095c2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org). ## [Unreleased] +## [3.2.0] - 2020-04-18 +### Added +- Create the destination branch (based on the default branch) if it doesn't exists. + ## [3.1.1] - 2020-04-01 ### Added - Add automatic updating of major version tag on release. diff --git a/README.md b/README.md index 8c99687..cc68d7a 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,8 @@ The following input variable options can/must be configured: |`dst_path`|Optional|The destination path to copy the file(s) or folder(s) to. For example `/wiki/` or `path/to/index.md`. |`src_path`| |`dst_owner`|Required|The name of the owner of the repository to push to. For example `andstor`.|| |`dst_repo_name`|Required|The name of the repository to push to. For example `copycat-action`.|| -|`src_branch`|Optional|The branch name of the source repository.|`master`| -|`dst_branch`|Optional|The branch name of the destination repository.|`master`| +|`src_branch`|Optional|The name of the branch in source repository to clone from.|`master`| +|`dst_branch`|Optional|The name of the branch in the destination repository to push to. If the branch doesn't exists, the branch will be created based on the default branch.|`master`| |`clean`|Optional|Set to `true` if the `dst_path` should be emptied before copying.|`false`| |`file_filter`|Optional|A simple [pattern](https://www.gnu.org/software/findutils/manual/html_mono/find.html#Shell-Pattern-Matching) for filtering files to be copied. Acts on file basename. For example `*.sh`.|| |`filter`|Optional|A glob pattern for filtering files to be copied. Acts on file paths. For example `**/!(*.*)`.|| diff --git a/entrypoint.sh b/entrypoint.sh index 00ce482..9f84e4d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,9 +1,9 @@ #!/bin/bash # # @author André Storhaug -# @date 2020-04-01 +# @date 2020-04-18 # @license MIT -# @version 3.1.0 +# @version 3.2.0 set -o pipefail @@ -112,8 +112,15 @@ fi git clone --branch ${DST_BRANCH} --single-branch --depth 1 https://${PERSONAL_TOKEN}@github.com/${DST_REPO}.git if [ "$?" -ne 0 ]; then - echo >&2 "Cloning '$DST_REPO' failed" - exit 1 + echo >&2 "Cloning branch '$DST_BRANCH' in '$DST_REPO' failed" + echo >&2 "Falling back to default branch" + git clone --single-branch --depth 1 https://${PERSONAL_TOKEN}@github.com/${DST_REPO}.git + echo >&2 "Creating branch '$DST_BRANCH'" + git checkout -b ${DST_BRANCH} + if [ "$?" -ne 0 ]; then + echo >&2 "Creation of Branch '$DST_BRANCH' failed" + exit 1 + fi fi if [ "$CLEAN" = "true" ]; then