1- name : ' Clone Github Repo Action '
1+ name : ' Clone Github Repo'
22
33description : " Github Action to clone a public or private Github repository and access its content on others repositories' workflows."
44
@@ -16,6 +16,10 @@ inputs:
1616 description : ' Depth of the clone (default: full history)'
1717 required : false
1818 default : " "
19+ branch :
20+ description : ' Branch name (default: main)'
21+ required : false
22+ default : " main"
1923
2024runs :
2125 using : ' composite'
@@ -24,21 +28,21 @@ runs:
2428 run : |
2529 if [ -z "${{ inputs.access-token }}" ]; then
2630 if [ -z "${{ inputs.depth }}" ]; then
27- git clone https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
31+ git clone --branch "${{ inputs.branch }}" https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
2832 else
29- git clone --depth="${{ inputs.depth }}" https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
33+ git clone --branch "${{ inputs.branch }}" -- depth="${{ inputs.depth }}" https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
3034 fi
3135 else
3236 if [ -z "${{ inputs.depth }}" ]; then
33- git clone https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
37+ git clone --branch "${{ inputs.branch }}" https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
3438 else
35- git clone --depth="${{ inputs.depth }}" https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
39+ git clone --branch "${{ inputs.branch }}" -- depth="${{ inputs.depth }}" https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
3640 fi
3741 fi
3842
3943 if [ -d "${{ inputs.repository }}" ]; then
4044 echo "Cloned ${{ inputs.repository }} repository successfully."
41- echo "Access the repository content using \"cd ${{ inputs.repository }}\"."
45+ echo "Access the repository content using \"cd ${{ inputs.repository }}.\""
4246 else
4347 echo "Error: Couldn't clone ${{ inputs.repository }} repository. Check the inputs or the PAT scope."
4448 exit 1
4852branding :
4953 icon : ' download'
5054 color : ' blue'
55+
0 commit comments