Skip to content

Commit 0dea35c

Browse files
committed
Update branch selector with condition judgement in the steps && judge whether the required value is input
with CI test of public repo "python-docs-zh-cn" with branch "3.10"
1 parent 6efce25 commit 0dea35c

File tree

2 files changed

+78
-38
lines changed

2 files changed

+78
-38
lines changed

.github/workflows/public-repo.yml

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,54 @@ jobs:
6262
echo "CLONED REPO"
6363
cd poc-github-actions
6464
ls -la
65-
shell: bash
65+
66+
job-public-repo-ubuntu-branch:
67+
runs-on: ubuntu-latest
68+
steps:
69+
- name: Clone python/python-docs-zh-cn PUBLIC repository with branch "3.10"
70+
uses: lipeilin375/clone-github-repo-action@main
71+
with:
72+
owner: 'python'
73+
repository: 'python-docs-zh-cn'
74+
branch: '3.10'
75+
- name: Access cloned repository content
76+
run: |
77+
echo "ROOT"
78+
ls -la
79+
echo "CLONED REPO"
80+
cd python-docs-zh-cn
81+
ls -la
82+
83+
job-public-repo-macos-branch:
84+
runs-on: macos-latest
85+
steps:
86+
- name: Clone python/python-docs-zh-cn PUBLIC repository with branch "3.10"
87+
uses: lipeilin375/clone-github-repo-action@main
88+
with:
89+
owner: 'python'
90+
repository: 'python-docs-zh-cn'
91+
branch: '3.10'
92+
- name: Access cloned repository content
93+
run: |
94+
echo "ROOT"
95+
ls -la
96+
echo "CLONED REPO"
97+
cd python-docs-zh-cn
98+
ls -la
99+
100+
job-public-repo-windows-branch:
101+
runs-on: windows-latest
102+
steps:
103+
- name: Clone python/python-docs-zh-cn PUBLIC repository with branch "3.10"
104+
uses: lipeilin375/clone-github-repo-action@main
105+
with:
106+
owner: 'python'
107+
repository: 'python-docs-zh-cn'
108+
branch: '3.10'
109+
- name: Access cloned repository content
110+
run: |
111+
echo "ROOT"
112+
ls -la
113+
echo "CLONED REPO"
114+
cd python-docs-zh-cn
115+
ls -la

action.yml

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,38 @@ name: 'Clone Github Repo Action'
33
description: "Github Action to clone a public or private Github repository and access its content on others repositories' workflows."
44

55
inputs:
6-
owner:
7-
description: 'Repository Owner'
8-
required: true
9-
repository:
10-
description: 'Repository name'
11-
required: true
12-
access-token:
13-
description: 'PAT with repository scope (https://github.com/settings/tokens)'
14-
required: false
15-
branch:
16-
desciption: 'Repository Branch'
17-
required: false
6+
owner:
7+
description: 'Repository Owner'
8+
required: true
9+
repository:
10+
description: 'Repository name'
11+
required: true
12+
access-token:
13+
description: 'PAT with repository scope (https://github.com/settings/tokens)'
14+
required: false
15+
branch:
16+
description: 'Repository Branch'
17+
required: false
1818

1919
runs:
20-
using: 'composite'
21-
steps:
20+
using: 'composite'
21+
steps:
22+
- name: Missing required value
23+
if: ${{ github.event.inputs.owner == '' || github.event.inputs.repository == '' }}
24+
run: echo "Missing Required Value!"
2225
- name: Clone repository
26+
if: ${{ github.event.inputs.owner != '' && github.event.inputs.repository != '' }}
2327
run: |
24-
if [ -z "${{ inputs.access-token }}" ]; then
25-
if [ -z "${{ inputs.branch }}" ]; then
26-
git clone https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
27-
else
28-
git clone https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git -b ${{ inputs.branch }}
29-
fi
28+
if [[ -z ${{ github.event.inputs.access-token }} && -z ${{ github.event.inputs.branch }} ]]; then
29+
git clone https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
30+
elif [[ -z ${{ github.event.inputs.access-token }} && -n ${{ github.event.inputs.branch }} ]]; then
31+
git clone https://github.com/${{ inputs.owner }}/${{ inputs.repository }}.git -b ${{ inputs.branch }}
32+
elif [[ -n ${{ github.event.inputs.access-token }} && -z ${{ github.event.inputs.branch }} ]]; then
33+
git clone https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
3034
else
31-
git clone https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
32-
if [ -z "${{ inputs.branch }}" ]; then
33-
git clone https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git
34-
else
35-
git clone https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git -b ${{ inputs.branch }}
36-
fi
37-
fi
38-
39-
if [ -d "${{ inputs.repository }}" ]; then
40-
echo "Cloned ${{ inputs.repository }} repository successfully."
41-
echo "Access the repository content using \"cd ${{ inputs.repository }}\"."
42-
else
43-
echo "Error: Couldn't clone ${{ inputs.repository }} repository. Check the inputs or the PAT scope."
44-
exit 1
45-
fi
35+
git clone https://${{ inputs.access-token }}@github.com/${{ inputs.owner }}/${{ inputs.repository }}.git -b ${{ inputs.branch }}
4636
shell: bash
4737

4838
branding:
49-
icon: 'download'
50-
color: 'blue'
39+
icon: 'download'
40+
color: 'blue'

0 commit comments

Comments
 (0)