Skip to content

Commit

Permalink
✨ (#338) use upstream default branch instead of configured (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasAugustin committed Jun 19, 2023
1 parent 154e9af commit 8cdaa04
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 41 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,16 @@ on:
workflow_dispatch:

jobs:

test-implementation-job:

runs-on: ubuntu-latest

steps:
# To use this repository's private action, you must check out the repository
-
name: Checkout
- name: Checkout
uses: actions/checkout@v3
-
name: Test action step
- name: Test action step
uses: ./ # Uses an action in the root directory
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_repo_path: AndreasAugustin/template.git
upstream_branch: main
is_dry_run: true
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ jobs:
|----|----|----|----|
| github_token | Token for the repo. Can be passed in using `$\{{ secrets.GITHUB_TOKEN }}` | `true` | |
| source_repo_path | Repository path of the template | `true` | |
| upstream_branch | The target branch | `true` | `main` |
| upstream_branch | The target branch | `false` | `<The_remote_default>` |
| source_repo_ssh_private_key | `[optional]` private ssh key for the source repository. [see](#private-template-repository)| `false` | |
| pr_branch_name_prefix | `[optional]` the prefix of branches created by this action | `false` | `chore/template_sync` |
| pr_title | `[optional]` the title of PRs opened by this action. Must be already created. | `false` | `upstream merge template repository` |
Expand Down Expand Up @@ -305,7 +305,8 @@ under the `Workflow permissions` section.

## Release Updates

starting with version v0.5.2-draft the `templateversionrc` file is not needed anymore. You can delete that file from the target repositories.
* :warning: starting with version v1.0.0 the `upstream_branch` variable default ist not `main` anymore. It is now set to the remote default branch.
* starting with version v0.5.2-draft the `templateversionrc` file is not needed anymore. You can delete that file from the target repositories.

## Debug

Expand Down
52 changes: 25 additions & 27 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'actions-template-sync'
description: 'Synchronises changes of the template repository'
author: 'AndreasAugustin'
name: "actions-template-sync"
description: "Synchronises changes of the template repository"
author: "AndreasAugustin"
branding:
icon: cloud
color: green
Expand All @@ -9,45 +9,43 @@ inputs:
description: 'Token for the repo. Can be passed in using $\{{ secrets.GITHUB_TOKEN }}'
required: true
source_repo_path:
description: 'Repository path of the template'
description: "Repository path of the template"
required: true
upstream_branch:
description: 'The target branch'
required: true
default: 'main'
description: "The target branch"
source_repo_ssh_private_key:
description: '[optional] private ssh key for the source repository. E.q. useful if using a private template repository.'
description: "[optional] private ssh key for the source repository. E.q. useful if using a private template repository."
pr_branch_name_prefix:
description: '[optional] the prefix of branches created by this action'
default: 'chore/template_sync'
description: "[optional] the prefix of branches created by this action"
default: "chore/template_sync"
pr_title:
description: '[optional] the title of PRs opened by this action'
default: 'upstream merge template repository'
description: "[optional] the title of PRs opened by this action"
default: "upstream merge template repository"
pr_labels:
description: '[optional] comma separated list of pull request labels'
description: "[optional] comma separated list of pull request labels"
pr_commit_msg:
description: '[optional] the commit message of the template merge'
default: 'chore(template): merge template changes :up:'
description: "[optional] the commit message of the template merge"
default: "chore(template): merge template changes :up:"
hostname:
description: '[optional] the hostname of the GitHub repository'
default: 'github.com'
description: "[optional] the hostname of the GitHub repository"
default: "github.com"
is_dry_run:
description: '[optional] set to true if you do not want to push the changes and not want to create a PR'
description: "[optional] set to true if you do not want to push the changes and not want to create a PR"
is_allow_hooks:
description: '[optional] set to true if you want to allow hooks. Use this functionality with caution!'
default: 'false'
description: "[optional] set to true if you want to allow hooks. Use this functionality with caution!"
default: "false"
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'
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'
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'
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'
description: "[optional] set the pull parameters for the remote repository"
runs:
using: 'docker'
image: 'src/Dockerfile'
using: "docker"
image: "src/Dockerfile"
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
SOURCE_REPO_PATH: ${{ inputs.source_repo_path }}
Expand Down
10 changes: 5 additions & 5 deletions src/sync_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ if [[ -z "${SOURCE_REPO}" ]]; then
exit 1;
fi

if [[ -z "${UPSTREAM_BRANCH}" ]]; then
err "Missing env variable 'UPSTREAM_BRANCH'";
exit 1;
fi

if ! [ -x "$(command -v gh)" ]; then
err "github-cli gh is not installed. 'https://github.com/cli/cli'";
exit 1;
fi

if [[ -z "${UPSTREAM_BRANCH}" ]]; then
UPSTREAM_BRANCH="$(git remote show origin | awk '/HEAD branch/ {print $NF}')"
info "Missing env variable 'UPSTREAM_BRANCH' setting to remote default ${UPSTREAM_BRANCH}";
fi

if [[ -n "${SRC_SSH_PRIVATEKEY_ABS_PATH}" ]]; then
debug "using ssh private key for private source repository"
export GIT_SSH_COMMAND="ssh -i ${SRC_SSH_PRIVATEKEY_ABS_PATH}"
Expand Down

0 comments on commit 8cdaa04

Please sign in to comment.