Skip to content

Commit 7ed86ca

Browse files
committed
Create and push branch in one step
1 parent 1cd0e1a commit 7ed86ca

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

.github/workflows/pin-system-tests.yaml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,12 @@ jobs:
3939
BRANCH=${{ steps.define-branch.outputs.branch }}
4040
if git ls-remote --heads origin "$BRANCH" | grep -q "$BRANCH"; then
4141
echo "creating_new_branch=false" >> "$GITHUB_OUTPUT"
42-
echo "Branch $BRANCH already exists - skipping creation"
42+
echo "Branch $BRANCH already exists - please delete it and re-run the workflow."
43+
exit 0
4344
else
4445
echo "creating_new_branch=true" >> "$GITHUB_OUTPUT"
4546
echo "Branch $BRANCH does not exist - creating it now"
4647
fi
47-
48-
- name: Create and push branch
49-
if: steps.check-branch.outputs.creating_new_branch == 'true'
50-
id: create-branch
51-
run: |
52-
git checkout -b "${{ steps.define-branch.outputs.branch }}"
53-
git push -u origin "${{ steps.define-branch.outputs.branch }}"
5448
5549
- name: Update system-tests references to latest commit SHA on main
5650
run: ./tooling/update_system_test_reference.sh
@@ -79,15 +73,17 @@ jobs:
7973
8074
- name: Push changes
8175
uses: DataDog/commit-headless@5a0f3876e0fbdd3a86b3e008acf4ec562db59eee # action/v2.0.1
82-
if: steps.check-changes.outputs.commit_changes == 'true'
76+
if: steps.check-changes.outputs.commit_changes == 'true' && steps.check-branch.outputs.creating_new_branch == 'true'
8377
with:
8478
token: "${{ steps.octo-sts.outputs.token }}"
8579
branch: "${{ steps.define-branch.outputs.branch }}"
80+
head-sha: "${{ github.sha }}"
81+
create-branch: true
8682
command: push
8783
commits: "${{ steps.create-commit.outputs.commit }}"
8884

8985
- name: Create pull request
90-
if: steps.check-changes.outputs.commit_changes == 'true'
86+
if: steps.check-changes.outputs.commit_changes == 'true' && steps.check-branch.outputs.creating_new_branch == 'true'
9187
env:
9288
GH_TOKEN: ${{ steps.octo-sts.outputs.token }}
9389
# base may need to be `release/v*`

0 commit comments

Comments
 (0)