Skip to content

Commit 1981756

Browse files
Merge pull request #10 from dabao1955/main
add submodule option
2 parents 7b67ff4 + 7764d1b commit 1981756

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Field | Mandatory | Observation
2828
**repository** | YES | Ex: `clone-github-repo-action` |
2929
**branch** | NO | Ex: `main` (default)
3030
**depth** | NO | 1 `Ex: most recent commit`
31+
**submodule** | NO | `false` or `true`
3132
**access-token** | NO | [How to create a PAT](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token)
3233

3334
You can use one of those as reference:

action.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ inputs:
2020
description: 'Branch name (default: main)'
2121
required: false
2222
default: "main"
23+
submodule:
24+
description: 'Clone with submodules'
25+
required: false
26+
default: "false"
2327

2428
runs:
2529
using: 'composite'
@@ -28,15 +32,31 @@ runs:
2832
run: |
2933
if [ -z "${{ inputs.access-token }}" ]; then
3034
if [ -z "${{ inputs.depth }}" ]; then
31-
git clone --branch "${{ inputs.branch }}" https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
35+
if [ "${{ inputs.submodule }}" = "true" ]; then
36+
git clone --branch "${{ inputs.branch }}" https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git --recursive
37+
else
38+
git clone --branch "${{ inputs.branch }}" https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
39+
fi
3240
else
33-
git clone --branch "${{ inputs.branch }}" --depth="${{ inputs.depth }}" https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
41+
if [ "${{ inputs.submodule }}" = "true" ]; then
42+
git clone --branch "${{ inputs.branch }}" --depth="${{ inputs.depth }}" https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git --recursive
43+
else
44+
git clone --branch "${{ inputs.branch }}" --depth="${{ inputs.depth }}" https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
45+
fi
3446
fi
3547
else
3648
if [ -z "${{ inputs.depth }}" ]; then
37-
git clone --branch "${{ inputs.branch }}" https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
49+
if [ "${{ inputs.submodule }}" = "true" ]; then
50+
git clone --branch "${{ inputs.branch }}" https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git --recursive
51+
else
52+
git clone --branch "${{ inputs.branch }}" https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
53+
fi
3854
else
39-
git clone --branch "${{ inputs.branch }}" --depth="${{ inputs.depth }}" https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
55+
if [ "${{ inputs.submodule }}" = "true" ]; then
56+
git clone --branch "${{ inputs.branch }}" --depth="${{ inputs.depth }}" https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git --recursive
57+
else
58+
git clone --branch "${{ inputs.branch }}" --depth="${{ inputs.depth }}" https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
59+
fi
4060
fi
4161
fi
4262

0 commit comments

Comments
 (0)