File tree 1 file changed +15
-13
lines changed
1 file changed +15
-13
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
- # Grabs the last 5 commit SHA's from the given branch, then purges any commits that do not have a passing CI build
2
+
3
+ branch=$1
4
+ output_file=$2
5
+ # Grabs the last 10 commit SHA's from the given branch, then purges any commits that do not have a passing CI build
3
6
iterations=0
4
- curl -s -H ' Accept: application/vnd.github.v3+json' " https://api.github.com/repos/k3s-io/k3s/commits?per_page=5&sha=$1 " | jq -r ' .[] | .sha' & > $2
5
- # The VMs take time on startup to hit googleapis.com, wait loop until we can
7
+ commits_str=$( curl -s -H ' Accept: application/vnd.github.v3+json' " https://api.github.com/repos/k3s-io/k3s/commits?per_page=10&sha=$branch " | jq -j -r ' .[] | .sha, " "' )
8
+ read -a commits <<< " $commits_str"
9
+
10
+ # The VMs take time on startup to hit aws, wait loop until we can
6
11
while ! curl -s --fail https://k3s-ci-builds.s3.amazonaws.com > /dev/null; do
7
12
(( iterations++ ))
8
13
if [ " $iterations " -ge 30 ]; then
@@ -12,15 +17,12 @@ while ! curl -s --fail https://k3s-ci-builds.s3.amazonaws.com > /dev/null; do
12
17
sleep 1
13
18
done
14
19
15
- iterations=0
16
- curl -s --fail https://k3s-ci-builds.s3.amazonaws.com/k3s-$( head -n 1 $2 ) .sha256sum
17
- while [ $? -ne 0 ]; do
18
- (( iterations++ ))
19
- if [ " $iterations " -ge 6 ]; then
20
- echo " No valid commits found"
21
- exit 1
20
+ for commit in " ${commits[@]} " ; do
21
+ if curl -s --fail https://k3s-ci-builds.s3.amazonaws.com/k3s-$commit .sha256sum > /dev/null; then
22
+ echo " $commit " > " $output_file "
23
+ exit 0
22
24
fi
23
- sed -i 1d " $2 "
24
- sleep 1
25
- curl -s --fail https://k3s-ci-builds.s3.amazonaws.com/k3s-$( head -n 1 $2 ) .sha256sum
26
25
done
26
+
27
+ echo " Failed to find a valid commit, checked: " " ${commits[@]} "
28
+ exit 1
You can’t perform that action at this time.
0 commit comments