Skip to content

Commit 29748b0

Browse files
fix(workflows): target repository default branch for auto PRs (#156)
Pass github.event.repository.default_branch to action-pull-request in the reusable auto-pull-request workflow so repositories using main, master, or a different default branch create PRs against the correct base branch. This makes the shared auto-PR flow fork-safe for repositories that consume the reusable workflow. Co-authored-by: ChristophShyper <45788587+ChristophShyper@users.noreply.github.com>
1 parent 6ab1f5d commit 29748b0

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

Taskfile.variables.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,21 @@ vars:
3838
DOCKER_NAME: '{{.DOCKER_ORG_NAME}}/{{.DOCKER_IMAGE}}'
3939
GITHUB_NAME: '{{.GITHUB_ORG_NAME}}/{{.GITHUB_REPO}}'
4040
GHRC_NAME: ghcr.io/{{.GITHUB_ORG_NAME}}/{{.GITHUB_REPO}}
41-
DEFAULT_BRANCH: master
41+
DEFAULT_BRANCH:
42+
sh: |
43+
if [ -n "${DEFAULT_BRANCH:-}" ]; then
44+
printf "%s\n" "${DEFAULT_BRANCH}"
45+
elif branch_ref="$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null)"; then
46+
printf "%s\n" "${branch_ref#origin/}"
47+
elif current_branch="$(git symbolic-ref --quiet --short HEAD 2>/dev/null)" && { [ "${current_branch}" = "main" ] || [ "${current_branch}" = "master" ]; }; then
48+
printf "%s\n" "${current_branch}"
49+
elif git show-ref --verify --quiet refs/heads/main || git show-ref --verify --quiet refs/remotes/origin/main; then
50+
echo main
51+
elif git show-ref --verify --quiet refs/heads/master || git show-ref --verify --quiet refs/remotes/origin/master; then
52+
echo master
53+
else
54+
echo master
55+
fi
4256
VERSION_FROM_ACTION_YML:
4357
sh: 'grep "image: docker://{{.DOCKER_NAME}}:" action.yml 2>/dev/null | cut -d ":" -f 4'
4458
AUTHOR_FROM_ACTION_YML:

0 commit comments

Comments
 (0)