@@ -6,7 +6,7 @@ helpFunction() {
6
6
echo -e " \t-p GitHub repository to clone, format: owner/repo"
7
7
echo -e " \t-f Reference of repository to clone"
8
8
exit 1
9
- }
9
+ } >&2
10
10
11
11
while getopts " p:f:" opt; do
12
12
case " $opt " in
@@ -17,17 +17,18 @@ while getopts "p:f:" opt; do
17
17
done
18
18
19
19
if [ -z " $github_repository " ] || [ -z " $git_ref " ]; then
20
- echo " some parameters are empty"
20
+ echo >&2 " some parameters are empty"
21
21
helpFunction
22
22
fi
23
23
24
- echo " Cloning repository $github_repository at ref $git_ref "
25
- git clone --bare --single-branch --branch " $git_ref " " https://github.com/$github_repository " bare_pr_preview
26
-
27
- cd bare_pr_preview || exit 1
28
-
29
- action_version=$( git describe --tags --match " v*.*.*" \
30
- || git describe --tags \
31
- || git rev-parse HEAD)
32
-
33
- echo " action_version=$action_version " >> " $GITHUB_ENV "
24
+ echo >&2 " Determining preview action version"
25
+ echo >&2 " Cloning repository $github_repository at ref $git_ref "
26
+ if git clone --bare --single-branch --branch " $git_ref " " https://github.com/$github_repository " bare_pr_preview; then
27
+ echo >&2 " Finding most specific tag matching tag $git_ref "
28
+ action_version=$( git describe --tags --match " v*.*.*" || git describe --tags || git rev-parse HEAD)
29
+ echo >&2 " Found $action_version "
30
+ echo " action_version=$action_version " >> " $GITHUB_ENV "
31
+ else
32
+ echo >&2 " Clone failed; using truncated ref as action version"
33
+ echo " action_version=${git_ref: 0: 9} " >> " $GITHUB_ENV "
34
+ fi
0 commit comments