diff --git a/README.md b/README.md index 346d140..a7cbdba 100644 --- a/README.md +++ b/README.md @@ -14,22 +14,22 @@ As with any Github Action, you must include it in a workflow for your repo to ru | Name | Required? | Default | Example | | ------------------- |:------------------: | ----------------- | ---------- -| upstream_repository | :white_check_mark: | | aormsby/Fork-Sync-With-Upstream-action | -| upstream_branch | :white_check_mark: | | 'master', 'main', 'dev' | -| target_branch | :white_check_mark: | | 'master', 'main', 'prod' | -| github_token | | | ${{ secrets.GITHUB_TOKEN }} | +| upstream_repository | :white_check_mark: | | aormsby/Fork-Sync-With-Upstream-action | +| upstream_branch | :white_check_mark: | | 'master', 'main', 'dev' | +| target_branch | :white_check_mark: | | 'master', 'main', 'prod' | +| github_token | | | ${{ secrets.GITHUB_TOKEN }} | For **github_token** - use `${{ secrets.GITHUB_TOKEN }}` where `GITHUB_TOKEN` is the name of the secret in your repo ([see docs for help](https://docs.github.com/en/actions/configuring-and-managing-workflows/using-variables-and-secrets-in-a-workflow)) #### Advanced Use (all optional args) -| Name | Required? | Default | Example | -| ------------------- |:------------------: | ----------------- | ---------- -| git_checkout_args | | | '--recurse-submodules' | -| git_fetch_args | | | '--tags' | -| git_log_format_args | | '--pretty=oneline' | '--graph --pretty=oneline' | -| git_sync_command | | 'pull' | 'pull' or 'merge --ff-only' or 'reset --hard' | -| git_push_args | | | '--force' | +| Name | Required? | Default | Example | +| ------------------- |:------------------: | ------------------ | ---------- +| git_checkout_args | | | '--recurse-submodules' | +| git_fetch_args | | | '--tags' | +| git_log_format_args | | '--pretty=oneline' | '--graph --pretty=oneline' | +| git_pull_args | | 'pull' | '--ff-only' | +| git_push_args | | | '--force' | ### Output Variables @@ -78,7 +78,7 @@ jobs: upstream_repository: panr/hugo-theme-hello-friend upstream_branch: master target_branch: master - git_sync_command: pull --ff-only # optional arg use, defaults to pull + git_pull_args: --ff-only # optional arg use, defaults to simple 'pull' github_token: ${{ secrets.GITHUB_TOKEN }} # optional, for accessing repos that require authentication # Step 3: Display a message if 'sync' step had new commits (simple test) diff --git a/action.yaml b/action.yaml index d5283f6..add4dac 100644 --- a/action.yaml +++ b/action.yaml @@ -38,10 +38,10 @@ inputs: required: false default: '--pretty=oneline' - git_sync_command: - description: 'Which git command to use for sync (eg "merge --ff-only" or "reset --hard"), default = pull' + git_pull_args: + description: 'Any extra args to pass to `git push` like --ff-only or --tags, default = ""' required: false - default: 'pull' + default: '' git_push_args: description: 'Any extra args to pass to `git push` like --force, default = ""' diff --git a/upstream-sync.sh b/upstream-sync.sh index 7a31fb8..3ce3395 100755 --- a/upstream-sync.sh +++ b/upstream-sync.sh @@ -1,7 +1,7 @@ #!/bin/sh set -e -# do not quote GIT_SYNC_COMMAND or GIT_*_ARGS. As they may contain +# do not quote GIT_PULL_ARGS or GIT_*_ARGS. As they may contain # more than one argument. # fail if upstream_repository is not set in workflow @@ -43,8 +43,8 @@ git log upstream/"${INPUT_UPSTREAM_BRANCH}" "${LOCAL_COMMIT_HASH}"..HEAD ${INPUT # sync from upstream to target_branch echo 'Syncing...' 1>&1 -# sync_command examples: "pull", "merge --ff-only", "reset --hard" -git ${INPUT_GIT_SYNC_COMMAND} upstream "${INPUT_UPSTREAM_BRANCH}" +# pull_args examples: "--ff-only", "--tags" +git pull ${INPUT_GIT_PULL_ARGS} upstream "${INPUT_UPSTREAM_BRANCH}" echo 'Sync successful' 1>&1 # push to origin target_branch