Skip to content

Commit

Permalink
Merge pull request #10 from dabao1955/main
Browse files Browse the repository at this point in the history
add submodule option
  • Loading branch information
GuillaumeFalourd authored Dec 14, 2023
2 parents 7b67ff4 + 7764d1b commit 1981756
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Field | Mandatory | Observation
**repository** | YES | Ex: `clone-github-repo-action` |
**branch** | NO | Ex: `main` (default)
**depth** | NO | 1 `Ex: most recent commit`
**submodule** | NO | `false` or `true`
**access-token** | NO | [How to create a PAT](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token)

You can use one of those as reference:
Expand Down
28 changes: 24 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ inputs:
description: 'Branch name (default: main)'
required: false
default: "main"
submodule:
description: 'Clone with submodules'
required: false
default: "false"

runs:
using: 'composite'
Expand All @@ -28,15 +32,31 @@ runs:
run: |
if [ -z "${{ inputs.access-token }}" ]; then
if [ -z "${{ inputs.depth }}" ]; then
git clone --branch "${{ inputs.branch }}" https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
if [ "${{ inputs.submodule }}" = "true" ]; then
git clone --branch "${{ inputs.branch }}" https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git --recursive
else
git clone --branch "${{ inputs.branch }}" https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
fi
else
git clone --branch "${{ inputs.branch }}" --depth="${{ inputs.depth }}" https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
if [ "${{ inputs.submodule }}" = "true" ]; then
git clone --branch "${{ inputs.branch }}" --depth="${{ inputs.depth }}" https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git --recursive
else
git clone --branch "${{ inputs.branch }}" --depth="${{ inputs.depth }}" https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
fi
fi
else
if [ -z "${{ inputs.depth }}" ]; then
git clone --branch "${{ inputs.branch }}" https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
if [ "${{ inputs.submodule }}" = "true" ]; then
git clone --branch "${{ inputs.branch }}" https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git --recursive
else
git clone --branch "${{ inputs.branch }}" https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
fi
else
git clone --branch "${{ inputs.branch }}" --depth="${{ inputs.depth }}" https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
if [ "${{ inputs.submodule }}" = "true" ]; then
git clone --branch "${{ inputs.branch }}" --depth="${{ inputs.depth }}" https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git --recursive
else
git clone --branch "${{ inputs.branch }}" --depth="${{ inputs.depth }}" https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
fi
fi
fi
Expand Down

0 comments on commit 1981756

Please sign in to comment.