Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Datree
Commits
a13a43bb
Unverified
Commit
a13a43bb
authored
3 years ago
by
Roy Hadad
Committed by
GitHub
3 years ago
Browse files
Options
Download
Email Patches
Plain Diff
ci: add polling to wait until travis build is finished (#277)
parent
12b96133
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.github/workflows/release.yml
+3
-12
.github/workflows/release.yml
.github/workflows/request-travis-build-and-wait-until-finished.sh
+64
-0
...workflows/request-travis-build-and-wait-until-finished.sh
with
67 additions
and
12 deletions
+67
-12
.github/workflows/release.yml
+
3
-
12
View file @
a13a43bb
...
...
@@ -45,7 +45,7 @@ jobs:
exit 1
fi
BODY="
REQUEST_BUILD_
BODY="
{
\"request\": {
\"branch\": \"$branch_name\",
...
...
@@ -62,23 +62,14 @@ jobs:
}
}
"
GH_ORGANIZATION_NAME="datreeio"
GH_REPOSITORY_NAME="datree"
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Travis-API-Version: 3" \
-H "Authorization: token ${TRAVIS_API_TOKEN}" \
-d "$BODY" \
"https://api.travis-ci.com/repo/${GH_ORGANIZATION_NAME}%2F${GH_REPOSITORY_NAME}/requests"
REQUEST_BUILD_BODY=$REQUEST_BUILD_BODY ./request-travis-build-and-wait-until-finished.sh
release-docker
:
env
:
REPO_NAME
:
datree
IMAGE_NAME
:
datree
name
:
Release container image to public registries
needs
:
[
release
,
define_version_job
]
needs
:
[
release
,
define_version_job
]
runs-on
:
ubuntu-latest
steps
:
-
uses
:
actions/checkout@v2
...
...
This diff is collapsed.
Click to expand it.
.github/workflows/request-travis-build-and-wait-until-finished.sh
0 → 100755
+
64
-
0
View file @
a13a43bb
#!/bin/bash
GH_ORGANIZATION_NAME
=
"datreeio"
GH_REPOSITORY_NAME
=
"datree"
GH_SLUG
=
${
GH_ORGANIZATION_NAME
}
%2F
${
GH_REPOSITORY_NAME
}
echo
"Requesting a travis build..."
request_build_response
=
$(
curl
-s
-X
POST
\
-H
"Content-Type: application/json"
\
-H
"Accept: application/json"
\
-H
"Travis-API-Version: 3"
\
-H
"Authorization: token
${
TRAVIS_API_TOKEN
}
"
\
-d
"
$REQUEST_BUILD_BODY
"
\
"https://api.travis-ci.com/repo/
${
GH_SLUG
}
/requests"
)
REQUEST_ID
=
$(
echo
$request_build_response
| jq
'.request.id'
)
echo
"Travis request id:
${
REQUEST_ID
}
"
is_travis_build_already_created
=
false
while
true
;
do
sleep
10
echo
"Polling travis build status..."
response
=
$(
curl
-s
-X
GET
\
-H
"Content-Type: application/json"
\
-H
"Accept: application/json"
\
-H
"Travis-API-Version: 3"
\
-H
"Authorization: token
${
TRAVIS_API_TOKEN
}
"
\
"https://api.travis-ci.com/repo/
${
GH_SLUG
}
/request/
${
REQUEST_ID
}
"
)
build_status
=
$(
echo
$response
| jq
'.builds[0].state'
)
build_request_state
=
$(
echo
$response
| jq
'.state'
)
if
[
$build_request_state
=
"
\"
pending
\"
"
]
;
then
echo
"Build request pending..."
elif
[
$build_status
=
"
\"
passed
\"
"
]
;
then
echo
"Travis build passed!"
exit
0
elif
[
$build_status
=
"
\"
failed
\"
"
]
;
then
echo
"Travis build failed!"
exit
1
elif
[
$build_status
=
"
\"
canceled
\"
"
]
;
then
echo
"Travis build canceled!"
exit
1
elif
[
$build_status
=
"
\"
created
\"
"
]
;
then
if
[
$is_travis_build_already_created
=
true
]
;
then
echo
"Travis build queued..."
else
echo
"Travis build created!"
fi
is_travis_build_already_created
=
true
elif
[
$build_status
=
"
\"
started
\"
"
]
;
then
echo
"Travis build in progress..."
else
echo
"Travis build unknown state!"
echo
"build_status:
${
build_status
}
"
echo
"REQUEST_ID:
${
REQUEST_ID
}
"
echo
"response:
${
response
}
"
exit
1
fi
done
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help