Skip to content

Commit 28c8012

Browse files
committed
New Feature - add branch selector
add a no required option named "branch", and when it exist value, then the action will clone the selected branch via git command, with "-b <branch name>"
1 parent 295f5b7 commit 28c8012

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Field | Mandatory | Observation
1919
**owner** | YES | Ex: `octocat`
2020
**repository** | YES | Ex: `clone-github-repo-action`
2121
**access-token** | NO | [How to create a PAT](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token)
22+
**branch** | NO | Ex: `main`
2223

2324
You can use one of those as reference:
2425

action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ inputs:
1212
access-token:
1313
description: 'PAT with repository scope (https://github.com/settings/tokens)'
1414
required: false
15+
branch:
16+
desciption: 'Repository Branch'
17+
required: false
1518

1619
runs:
1720
using: 'composite'
@@ -20,6 +23,11 @@ runs:
2023
run: |
2124
if [ -z "${{ inputs.access-token }}" ]; then
2225
git clone https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
26+
if [ -z "${{ inputs.branch }}" ]; then
27+
git clone https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
28+
else
29+
git clone https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git -b ${{ inputs.branch }}
30+
fi
2331
else
2432
git clone https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
2533
fi

0 commit comments

Comments
 (0)