@@ -15,6 +15,8 @@ DO_CLEANUP=0
15
15
declare -A FAILURE_TESTS
16
16
declare SIGNAL # used to record signal caught by trap
17
17
18
+ BRANCH_TIMEOUT_SEC=10800
19
+
18
20
context_name=$1
19
21
context_repo=$2
20
22
@@ -69,6 +71,26 @@ function cleanup ()
69
71
werft log slice " clean up" --done
70
72
}
71
73
74
+ function gc_integration_branches ()
75
+ {
76
+ werft log phase " GC too old integration branches" " GC too old integration branches"
77
+ now=$( date --utc +%s)
78
+ for br in $( git branch --format=" %(refname:short)" -a | grep -v HEAD) ; do
79
+ if echo $br | grep -q " origin/wk-inte-test/*" ; then
80
+ last_commite_date=$( date --utc --date " $( git show --format=" %ci" $br | head -n 1) " +%s)
81
+ diff=$(( $now - $last_commite_date ))
82
+ if [[ $diff > $BRANCH_TIMEOUT_SEC ]]; then
83
+ local_branch_name=$( echo $br | cut -d ' /' -f2-)
84
+ werft log slice " delete $local_branch_name "
85
+ set +e
86
+ git push origin :" $local_branch_name "
87
+ set -e
88
+ werft log slice " delete $local_branch_name " --done
89
+ fi
90
+ fi
91
+ done
92
+ }
93
+
72
94
sudo chown -R gitpod:gitpod /workspace
73
95
gcloud auth activate-service-account --key-file /mnt/secrets/gcp-sa/service-account.json
74
96
export GOOGLE_APPLICATION_CREDENTIALS=
" /home/gitpod/.config/gcloud/legacy_credentials/[email protected] /adc.json"
@@ -77,6 +99,8 @@ git config --global user.name roboquat
77
99
git config --global user.email
[email protected]
78
100
git remote set-url origin https://oauth2:" ${ROBOQUAT_TOKEN} " @github.com/gitpod-io/gitpod.git
79
101
102
+ gc_integration_branches
103
+
80
104
werft log phase " build preview environment" " build preview environment"
81
105
82
106
# Create a new branch and asks Werft to create a preview environment for it
185
209
done
186
210
187
211
exit $FAILURE_COUNT
212
+
0 commit comments