Skip to content

Commit c17fe7c

Browse files
Promote develop/1.0 to preview/1.0 (#207)
`gh pr create --fill` computes the PR body by running `git log origin/<target>...HEAD`, but the shallow checkout (`fetch-depth: 1`) only fetches the source branch. With `origin/<target>` absent from the local repo, git fails with "ambiguous argument" and the job exits non-zero. ## Changes - **`.github/workflows/promote-branch.yml`** — add `git fetch origin ${{ env.target-branch }}` immediately before `gh pr create` in the "Create PR" step, ensuring the remote tracking ref exists when `--fill` computes the commit range.
1 parent 5cc4de7 commit c17fe7c

8 files changed

Lines changed: 29 additions & 17 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: 'Configure git identity'
2+
author: 'Pete Sramek'
3+
description: 'Configures git user name and email from the last commit.'
4+
5+
runs:
6+
using: composite
7+
steps:
8+
- name: 'Configure git identity'
9+
shell: bash
10+
run: |
11+
git config user.name "$(git log -n 1 --pretty=format:%an)"
12+
git config user.email "$(git log -n 1 --pretty=format:%ae)"

.github/actions/git/push-changes/action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,14 @@ runs:
8787
set -e
8888
working-directory: ${{ inputs.working-directory }}
8989

90+
- name: Configure git identity
91+
if: ${{ fromJSON(steps.validate.outputs.has-changes) == '1' }}
92+
uses: './.github/actions/git/configure-identity'
93+
9094
- name: Push changes to ${{ github.head_ref || github.ref }}
9195
if: ${{ fromJSON(steps.validate.outputs.has-changes) == '1' }}
9296
shell: bash
9397
run: |
94-
git config user.name "$(git log -n 1 --pretty=format:%an)"
95-
git config user.email "$(git log -n 1 --pretty=format:%ae)"
9698
git commit -m '${{ inputs.commit-message }}'
9799
git pull --rebase origin ${{ github.head_ref || github.ref }}
98100
git push

.github/actions/github/create-release/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ runs:
2525
echo "notes-start-tag=${{ inputs.notes-start-tag }}"
2626
echo "notes-start-tag-argument=${{ inputs.notes-start-tag != '' && format('--notes-start-tag {0}', inputs.notes-start-tag) || '' }}"
2727
shell: bash
28+
- name: 'Configure git identity'
29+
uses: './.github/actions/git/configure-identity'
2830
- name: 'Create git tag ${{ inputs.release-version }}'
2931
shell: bash
3032
run: |

.github/workflows/backtrack.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ jobs:
3030
token: ${{ secrets.GH_ADMIN_TOKEN }}
3131

3232
- name: 'Configure git'
33-
run: |
34-
git config user.name "$(git log -n 1 --pretty=format:%an)"
35-
git config user.email "$(git log -n 1 --pretty=format:%ae)"
33+
uses: './.github/actions/git/configure-identity'
3634

3735
- name: 'Resolve backtrack targets'
3836
id: targets

.github/workflows/bump-version.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ jobs:
113113
dotnet-version: ${{ env.dotnet-sdk-version }}
114114

115115
- name: 'Configure git'
116-
run: |
117-
git config user.name "$(git log -n 1 --pretty=format:%an)"
118-
git config user.email "$(git log -n 1 --pretty=format:%ae)"
116+
uses: './.github/actions/git/configure-identity'
119117

120118
- name: 'Create develop branch from main'
121119
run: |

.github/workflows/promote-branch.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ jobs:
6060
target-branch-exists: ${{ steps.check-target-branch-exists.outputs.target-branch-exists }}
6161
pull-request-exists: ${{ steps.check-pull-request-exists.outputs.pull-request-exists }}
6262
steps:
63+
- name: 'Checkout ${{ github.head_ref || github.ref }}'
64+
uses: actions/checkout@v6
6365
- name: 'Set target branch'
6466
id: set-target-branch
6567
run: |
@@ -211,17 +213,12 @@ jobs:
211213
run: |
212214
git fetch origin
213215
git push origin origin/${{ env.base-branch }}:refs/heads/${{ env.target-branch }}
214-
- name: 'Lock target branch'
215-
if: ${{ needs.workflow-variables.outputs.target-branch-exists == 'false' }}
216-
uses: './.github/actions/github/branch-protection/lock'
217-
with:
218-
branch: ${{ needs.workflow-variables.outputs.target-branch }}
219-
token: ${{ secrets.GH_ADMIN_TOKEN }}
220216
- name: 'Create PR: "Promote ${{ env.current-branch }} to ${{ env.target-branch }}"'
221217
if: ${{ needs.workflow-variables.outputs.pull-request-exists == 'false' }}
222218
env:
223219
GH_TOKEN: ${{ github.token }}
224220
current-branch: ${{ github.ref_name }}
225221
target-branch: ${{ needs.workflow-variables.outputs.target-branch }}
226222
run: |
223+
git fetch origin ${{ env.target-branch }}
227224
gh pr create --title "Promote ${{ env.current-branch }} to ${{ env.target-branch }}" --fill --base ${{ env.target-branch }} --head ${{ env.current-branch }}

.github/workflows/pull-request.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ on:
88
- synchronize
99
- reopened
1010
branches:
11+
- 'develop/**'
1112
- 'preview/**'
12-
- 'release/**'
13+
- 'release/**'
1314

1415
permissions:
1516
actions: read

.github/workflows/release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,13 @@ jobs:
358358
echo "support-branch-exists=false" >> $GITHUB_OUTPUT
359359
fi
360360
361+
- name: 'Configure git identity'
362+
if: ${{ steps.check-support-branch.outputs.support-branch-exists == 'false' }}
363+
uses: './.github/actions/git/configure-identity'
364+
361365
- name: 'Create support branch'
362366
if: ${{ steps.check-support-branch.outputs.support-branch-exists == 'false' }}
363367
run: |
364-
git config user.name "$(git log -n 1 --pretty=format:%an)"
365-
git config user.email "$(git log -n 1 --pretty=format:%ae)"
366368
git checkout -b "${{ steps.resolve-support-branch.outputs.support-branch }}"
367369
git push --set-upstream origin "${{ steps.resolve-support-branch.outputs.support-branch }}"
368370

0 commit comments

Comments
 (0)