-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·83 lines (61 loc) · 1.88 KB
/
entrypoint.sh
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
75
76
77
78
79
80
81
82
83
#!/bin/sh -l
# args: ref show history
set -eu
git config --global --add safe.directory /github/workspace
# TODO maybe we can skip ALL commits
# https://stackoverflow.com/questions/10312521/how-to-fetch-all-git-branches
git tag | xargs git tag -d
for remote in `git branch -r`; do
git branch --track ${remote#origin/} $remote || \
echo "Failed to track `$remote` branch: already tracked or doesn't exist."
done
git fetch --all --prune --tags
echo "\n\n============ GTO ============\n"
echo "The Git ref that triggered this run: $GITHUB_REF"
export NAME=`gto check-ref $GITHUB_REF --name`
export VERSION=`gto check-ref $GITHUB_REF --version`
export EVENT=`gto check-ref $GITHUB_REF --event`
if [ "$EVENT" = "assignment" ]; then
export STAGE=`gto check-ref $GITHUB_REF --stage`
else
export STAGE=""
fi
if [ $NAME ]; then
export TYPE=$(python /read_annotation.py type)
export DESC=$(python /read_annotation.py desc)
export ARTIFACT_PATH=$(python /read_annotation.py path)
else
export TYPE=""
export DESC=""
export ARTIFACT_PATH=""
fi
if [ $NAME ]; then
gto show $NAME
gto history $NAME
fi
if [ "$2" = "true" ]; then
gto show
fi
if [ "$3" = "true" ]; then
gto history
fi
echo "name=$NAME" >> $GITHUB_OUTPUT
echo "stage=$STAGE" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "event=$EVENT" >> $GITHUB_OUTPUT
echo "type=$TYPE" >> $GITHUB_OUTPUT
echo "path=$ARTIFACT_PATH" >> $GITHUB_OUTPUT
echo "description=$DESC" >> $GITHUB_OUTPUT
if [ "$4" = "true" ]; then
echo "\nAfter Git tag parsing, the following outputs are set:"
cat $GITHUB_OUTPUT
echo "\n"
fi
if [ "$5" = "true" ]; then
if [ -z "$ARTIFACT_PATH" ]; then
echo "\nAnnotation is not found, can't `dvc pull` the artifact. Exiting the action."
exit 1
fi
dvc pull $ARTIFACT_PATH || exit 1
echo "\nThe artifact now can be found at its path. Use action outputs to find it out."
fi