Skip to content

Commit 549bc0a

Browse files
committed
refactor: use actions/checkout ref parameter instead of separate git commands
Much cleaner approach using the built-in ref parameter of actions/checkout to directly checkout the target branch instead of manual git commands. Uses: ref: ${{ inputs.target-branch || github.ref }} - If target-branch is provided, checkout that branch - Otherwise, use the default behavior (github.ref)
1 parent 9ab4c43 commit 549bc0a

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

updater/action.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,7 @@ runs:
108108
uses: actions/checkout@v4
109109
with:
110110
token: ${{ inputs.api-token }}
111-
112-
- name: Checkout target branch
113-
if: inputs.target-branch != ''
114-
shell: bash
115-
run: |
116-
git fetch origin ${{ inputs.target-branch }}:${{ inputs.target-branch }}
117-
git checkout ${{ inputs.target-branch }}
111+
ref: ${{ inputs.target-branch || github.ref }}
118112

119113
- name: Update to the latest version
120114
id: target
@@ -241,13 +235,7 @@ runs:
241235
uses: actions/checkout@v4
242236
with:
243237
token: ${{ inputs.api-token }}
244-
245-
- name: 'After new PR: checkout target branch'
246-
if: ${{ inputs.target-branch != '' && ( steps.target.outputs.latestTag != steps.target.outputs.originalTag ) && ( steps.existing-pr.outputs.url == '') && ( steps.root.outputs.changed == 'false') }}
247-
shell: bash
248-
run: |
249-
git fetch origin ${{ inputs.target-branch }}:${{ inputs.target-branch }}
250-
git checkout ${{ inputs.target-branch }}
238+
ref: ${{ inputs.target-branch || github.ref }}
251239

252240
- name: 'After new PR: redo the update'
253241
if: ${{ ( steps.target.outputs.latestTag != steps.target.outputs.originalTag ) && ( steps.existing-pr.outputs.url == '') && ( steps.root.outputs.changed == 'false') }}

0 commit comments

Comments
 (0)