Skip to content

Commit

Permalink
feat: 🚀 (#328 #316) add params for git user.name, user.email a… (#330)
Browse files Browse the repository at this point in the history
* feat: 🚀 (#328 #316) add params for git user.name, user.email and git remote pull params

* doc: 📝 fix linter issue

* fix: 🐛 fix default variable

* fix: 🐛 fix cmd args from string

* fix: 🐛 fix cmd args from string

* fix: 🐛 fix cmd args from string

* fix: 🐛 fix cmd args from string

* doc: 📝 version bump v0.8.0
  • Loading branch information
AndreasAugustin committed Mar 21, 2023
1 parent e23a2c4 commit 6038fdf
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/actions_template_sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: actions-template-sync
uses: AndreasAugustin/actions-template-sync@v0.7.3
uses: AndreasAugustin/actions-template-sync@v0.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_repo_path: AndreasAugustin/template
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ keywords:
- github
- repo-sync
license: MIT
version: v0.7.3
version: v0.8.0
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: actions-template-sync
uses: AndreasAugustin/actions-template-sync@v0.7.3
uses: AndreasAugustin/actions-template-sync@v0.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_repo_path: <owner/repo>
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
private_key: ${{ secrets.PRIVATE_KEY }}

- name: actions-template-sync
uses: AndreasAugustin/actions-template-sync@v0.7.3
uses: AndreasAugustin/actions-template-sync@v0.8.0
with:
github_token: ${{ steps.generate_token.outputs.token }}
source_repo_path: <owner/repo>
Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: actions-template-sync
uses: AndreasAugustin/actions-template-sync@v0.7.3
uses: AndreasAugustin/actions-template-sync@v0.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_repo_path: ${{ secrets.SOURCE_REPO_PATH }} # <owner/repo>, should be within secrets
Expand Down Expand Up @@ -198,7 +198,7 @@ jobs:
uses: actions/checkout@v3
-
name: Test action step PAT
uses: AndreasAugustin/actions-template-sync@v0.7.3
uses: AndreasAugustin/actions-template-sync@v0.8.0
with:
github_token: ${{ secrets.SOURCE_REPO_PAT }}
source_repo_path: ${{ secrets.SOURCE_REPO_PATH }} # <owner/repo>, should be within secrets
Expand All @@ -220,6 +220,9 @@ jobs:
| is_dry_run | `[optional]` set to `true` if you do not want to push the changes and not want to create a PR | `false` | |
| is_allow_hooks | `[optional]` set to `true` if you want to enable lifecycle hooks. Use this with caution! | `false` | `false` |
| is_not_source_github | `[optional]` set to `true` if the source git provider is not GitHub | `false` | `false` |
| git_user_name | `[optional]` set the committer git user.name | `false` | `${GITHUB_ACTOR}` |
| git_user_email | `[optional]` set the committer git user.email | `false` | `[email protected].${SOURCE_REPO_HOSTNAME}` |
| git_remote_pull_params |`[optional]` set remote pull parameters | `false` | `--allow-unrelated-histories --squash --strategy=recursive -X theirs` |

### Example

Expand Down
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ inputs:
is_not_source_github:
description: '[optional] set to true if the source repository is not a github related repository. Useful e.q. if the source is GitLab'
default: 'false'
git_user_name:
description: '[optional] set the committer git user.name for the merge commit'
git_user_email:
description: '[optional] set the committer git user.email for the merge commit'
git_remote_pull_params:
description: '[optional] set the pull parameters for the remote repository'
runs:
using: 'docker'
image: 'src/Dockerfile'
Expand All @@ -55,3 +61,6 @@ runs:
IS_DRY_RUN: ${{ inputs.is_dry_run }}
IS_ALLOW_HOOKS: ${{ inputs.is_allow_hooks }}
IS_NOT_SOURCE_GITHUB: ${{ inputs.is_not_source_github }}
GIT_USER_NAME: ${{ inputs.git_user_name }}
GIT_USER_EMAIL: ${{ inputs.git_user_email }}
GIT_REMOTE_PULL_PARAMS: ${{ inputs.git_remote_pull_params }}
6 changes: 4 additions & 2 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ fi

DEFAULT_REPO_HOSTNAME="github.com"
SOURCE_REPO_HOSTNAME="${HOSTNAME:-${DEFAULT_REPO_HOSTNAME}}"
GIT_USER_NAME="${GIT_USER_NAME:-${GITHUB_ACTOR}}"
GIT_USER_EMAIL="${GIT_USER_EMAIL:-github-action@actions-template-sync.noreply.${SOURCE_REPO_HOSTNAME}}"

# In case of ssh template repository this will be overwritten
SOURCE_REPO_PREFIX="https://${SOURCE_REPO_HOSTNAME}/"
Expand Down Expand Up @@ -52,8 +54,8 @@ function git_init() {
echo "::group::git init"
info "set git global configuration"

git config --global user.email "[email protected].${SOURCE_REPO_HOSTNAME}"
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GIT_USER_EMAIL}"
git config --global user.name "${GIT_USER_NAME}"
git config --global pull.rebase false
git config --global --add safe.directory /github/workspace
git lfs install
Expand Down
5 changes: 3 additions & 2 deletions src/sync_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ if [[ -n "${SRC_SSH_PRIVATEKEY_ABS_PATH}" ]]; then
export GIT_SSH_COMMAND="ssh -i ${SRC_SSH_PRIVATEKEY_ABS_PATH}"
fi

GIT_REMOTE_PULL_PARAMS="${GIT_REMOTE_PULL_PARAMS:---allow-unrelated-histories --squash --strategy=recursive -X theirs}"

cmd_from_yml_file "install"

TEMPLATE_SYNC_IGNORE_FILE_PATH=".templatesyncignore"
Expand Down Expand Up @@ -68,8 +70,7 @@ debug "create new branch from default branch with name ${NEW_BRANCH}"
git checkout -b "${NEW_BRANCH}"
debug "pull changes from template"

# TODO(anau) eventually make squash optional
git pull "${SOURCE_REPO}" --allow-unrelated-histories --squash --strategy=recursive -X theirs
eval "git pull ${SOURCE_REPO} ${GIT_REMOTE_PULL_PARAMS}"
echo "::endgroup::"

# Check if the Ignore File exists inside .github folder or if it doesn't exist at all
Expand Down

0 comments on commit 6038fdf

Please sign in to comment.