Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ settings -> actions -> general.
* `metadata` -> read
* `pull requests` -> write

If you are automatically adding reviewers you also need
If you are automatically adding reviewers or assignees you also need

* `organisation:members` read permissions to the PAT token.
* `organisation:members` read permissions to the PAT token (so GitHub can resolve organization members as reviewers or assignees).

![pat-scopes-fine-grained](docs/assets/pat_fine_grained_needed_scopes.png)

Expand Down Expand Up @@ -297,6 +297,7 @@ jobs:
| pr_body | `[optional]` the body of PRs opened by this action. | `false` | `Merge ${SOURCE_REPO} ${TEMPLATE_GIT_HASH}` |
| pr_labels | `[optional]` comma separated list. [pull request labels][pr-labels]. | `false` | `sync_template` |
| pr_reviewers | `[optional]` comma separated list of pull request reviewers. | `false` | |
| pr_assignees | `[optional]` comma separated list of pull request assignees. | `false` | |
| pr_commit_msg | `[optional]` commit message in the created pull request | `false` | `chore(template): merge template changes :up:` |
| hostname | `[optional]` the hostname of the repository | `false` | `github.com` |
| is_git_lfs | `[optional]` set to `true` if you want to enalbe git lfs | `false` | `false` |
Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ inputs:
required: false
default: ${{ github.token }}
github_token:
deprecationMessage: 'please use source_gh_token instead to have a declarative name'
deprecationMessage: "please use source_gh_token instead to have a declarative name"
description: 'GitHub Token for the repo to be synced from. Can be passed in using $\{{ secrets.GITHUB_TOKEN }}'
required: false
source_repo_path:
Expand All @@ -37,6 +37,8 @@ inputs:
default: "template_sync"
pr_reviewers:
description: "[optional] comma separated list of pull request reviewers"
pr_assignees:
description: "[optional] comma separated list of pull request assignees"
pr_commit_msg:
description: "[optional] the commit message of the template merge"
default: "chore(template): merge template changes :up:"
Expand Down Expand Up @@ -119,6 +121,7 @@ runs:
PR_BODY: ${{ inputs.pr_body }}
PR_LABELS: ${{ inputs.pr_labels }}
PR_REVIEWERS: ${{ inputs.pr_reviewers }}
PR_ASSIGNEES: ${{ inputs.pr_assignees }}
PR_COMMIT_MSG: ${{ inputs.pr_commit_msg }}
HOSTNAME: ${{ inputs.hostname }}
IS_DRY_RUN: ${{ inputs.is_dry_run }}
Expand Down
17 changes: 11 additions & 6 deletions src/sync_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ function push () {
# branch
# labels
# reviewers
# assignees
###################################
function create_pr() {
info "create pr"
Expand All @@ -371,13 +372,15 @@ function create_pr() {
local branch=$3
local labels=$4
local reviewers=$5
local assignees=$6

gh pr create \
--title "${title}" \
--body "${body}" \
--base "${branch}" \
--label "${labels}" \
--reviewer "${reviewers}" || create_pr_has_issues=true
--reviewer "${reviewers}" \
--assignee "${assignees}" || create_pr_has_issues=true

if [ "$create_pr_has_issues" == true ] ; then
warn "Creating the PR failed."
Expand All @@ -395,6 +398,7 @@ function create_pr() {
# upstream_branch
# labels
# reviewers
# assignees
###################################
function create_or_edit_pr() {
info "create pr or edit the pr"
Expand All @@ -403,13 +407,14 @@ function create_or_edit_pr() {
local upstream_branch=$3
local labels=$4
local reviewers=$5
local pr_branch=$6
local assignees=$6

create_pr "${title}" "${body}" "${upstream_branch}" "${labels}" "${reviewers}" || gh pr edit \
create_pr "${title}" "${body}" "${upstream_branch}" "${labels}" "${reviewers}" "${assignees}" || gh pr edit \
--title "${title}" \
--body "${body}" \
--add-label "${labels}" \
--add-reviewer "${reviewers}"
--add-reviewer "${reviewers}" \
--add-assignee "${assignees}"
}

#########################################
Expand Down Expand Up @@ -551,9 +556,9 @@ function arr_prepare_pr_create_pr() {

cmd_from_yml "prepr"
if [ "$IS_FORCE_PUSH_PR" == true ] ; then
create_or_edit_pr "${PR_TITLE}" "${PR_BODY}" "${UPSTREAM_BRANCH}" "${PR_LABELS}" "${PR_REVIEWERS}"
create_or_edit_pr "${PR_TITLE}" "${PR_BODY}" "${UPSTREAM_BRANCH}" "${PR_LABELS}" "${PR_REVIEWERS}" "${PR_ASSIGNEES}"
else
create_pr "${PR_TITLE}" "${PR_BODY}" "${UPSTREAM_BRANCH}" "${PR_LABELS}" "${PR_REVIEWERS}"
create_pr "${PR_TITLE}" "${PR_BODY}" "${UPSTREAM_BRANCH}" "${PR_LABELS}" "${PR_REVIEWERS}" "${PR_ASSIGNEES}"
fi

PR_NUMBER="$(gh pr view "$PR_BRANCH" --json number --jq '.number' 2>/dev/null || true)"
Expand Down