From cb89c8896a58539de04d1ba46100e69fc3e08145 Mon Sep 17 00:00:00 2001 From: Andy Augustin Date: Wed, 2 Mar 2022 22:16:17 +0100 Subject: [PATCH] feat(hostname): add hostname :rocket: --- README.md | 7 ++++--- action.yml | 8 ++++++-- src/entrypoint.sh | 8 +++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a43e6a55..446c8304 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: actions-template-sync - uses: AndreasAugustin/actions-template-sync@v0.2.1-draft + uses: AndreasAugustin/actions-template-sync@v0.3.0-draft with: github_token: ${{ secrets.GITHUB_TOKEN }} source_repo_path: @@ -59,7 +59,8 @@ You will receive a pull request within your repository if there are some changes | source_repo_path | Repository path of the template | `true` | | | upstream_branch | The target branch | `true` | `main` | | source_repo_ssh_private_key | `[optional]` private ssh key for the source repository. E.q. useful if using a private template repository. [see](#private-template-repository)| `false` | | -| pr_labels | `[optional]` comma separated list. [pull request labels][pr-labels] | `false` | `chore,template_sync` | +| pr_labels | `[optional]` comma separated list. [pull request labels][pr-labels]. Must be already created. | `false` | `chore,template_sync` | +| hostname | `[optional]` the hostname of the repository | `false` | `github.com` | ### Example @@ -91,7 +92,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: actions-template-sync - uses: AndreasAugustin/actions-template-sync@v0.2.1-draft + uses: AndreasAugustin/actions-template-sync@v0.3.0-draft with: github_token: ${{ secrets.GITHUB_TOKEN }} source_repo_path: ${{ secrets.SOURCE_REPO_PATH }} # , should be within secrets diff --git a/action.yml b/action.yml index 350ad927..ae62b836 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,9 @@ inputs: pr_labels: description: '[optional] comma separated list of pull request labels' default: 'chore,template-sync' + hostname: + description: '[optional] the hostname of the GitHub repository' + default: 'github.com' runs: using: 'docker' image: 'src/Dockerfile' @@ -27,5 +30,6 @@ runs: GITHUB_TOKEN: ${{ inputs.github_token }} SOURCE_REPO_PATH: ${{ inputs.source_repo_path }} UPSTREAM_BRANCH: ${{ inputs.upstream_branch }} - SSH_PRIVATE_KEY_SRC: ${{ inputs.source_repo_ssh_private_key}} - PR_LABELS: ${{inputs.pr_labels}} + SSH_PRIVATE_KEY_SRC: ${{ inputs.source_repo_ssh_private_key }} + PR_LABELS: ${{ inputs.pr_labels }} + HOSTNAME: ${{ inputs.hostname }} diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 8121340d..a1a59826 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -13,8 +13,10 @@ if [[ -z "${SOURCE_REPO_PATH}" ]]; then exit 1 fi +SOURCE_REPO_HOSTNAME="${HOSTNAME:-github.com}" + # In case of private template repository this will be overwritten -SOURCE_REPO_PREFIX="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/" +SOURCE_REPO_PREFIX="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@${SOURCE_REPO_HOSTNAME}/" # Forward to /dev/null to swallow the output of the private key if [[ -n "${SSH_PRIVATE_KEY_SRC}" ]] &>/dev/null; then @@ -26,14 +28,14 @@ if [[ -n "${SSH_PRIVATE_KEY_SRC}" ]] &>/dev/null; then # use cat <<< instead of echo to swallow output of the private key cat <<< "${SSH_PRIVATE_KEY_SRC}" | sed 's/\\n/\n/g' > "${SRC_SSH_PRIVATEKEY_ABS_PATH}" chmod 600 "${SRC_SSH_PRIVATEKEY_ABS_PATH}" - SOURCE_REPO_PREFIX="git@github.com:" + SOURCE_REPO_PREFIX="git@${SOURCE_REPO_HOSTNAME}:" fi export SOURCE_REPO="${SOURCE_REPO_PREFIX}${SOURCE_REPO_PATH}" echo "::group::git init" echo "set git global configuration" -git config --global user.email "github-action@actions-template-sync.noreply.github.com" +git config --global user.email "github-action@actions-template-sync.noreply.${SOURCE_REPO_HOSTNAME}" git config --global user.name "${GITHUB_ACTOR}" git config --global pull.rebase false echo "::endgroup::"