-
Notifications
You must be signed in to change notification settings - Fork 20
/
action.yml
75 lines (69 loc) · 3.03 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: 'Clone Github Repo Action'
description: "Github Action to clone a public or private Github repository and access its content on others repositories' workflows."
inputs:
owner:
description: 'Repository Owner'
required: true
repository:
description: 'Repository name'
required: true
access-token:
description: 'PAT with repository scope (https://github.com/settings/tokens)'
required: false
depth:
description: 'Depth of the clone (default: full history)'
required: false
default: ""
branch:
description: 'Branch name (default: main)'
required: false
default: "main"
submodule:
description: 'Clone with submodules'
required: false
default: "false"
runs:
using: 'composite'
steps:
- name: Clone repository
run: |
if [ -z "${{ inputs.access-token }}" ]; then
if [ -z "${{ inputs.depth }}" ]; then
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
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
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
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
if [ -d "${{ inputs.repository }}" ]; then
echo "Cloned ${{ inputs.repository }} repository successfully."
echo "Access the repository content using \"cd ${{ inputs.repository }}.\""
else
echo "Error: Couldn't clone ${{ inputs.repository }} repository. Check the inputs or the PAT scope."
exit 1
fi
shell: bash
branding:
icon: 'download'
color: 'blue'