Skip to content

Commit f97b150

Browse files
gavin-stackroxRoxBot
authored andcommitted
a nightly update script
1 parent f178c11 commit f97b150

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

.openshift-ci/nightlies.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
3+
# The handler for nightly CI defined in:
4+
# https://github.com/openshift/release/tree/master/ci-operator/config/stackrox/stackrox/stackrox-stackrox-nightlies.yaml
5+
6+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
7+
source "$ROOT/scripts/ci/lib.sh"
8+
9+
set -euo pipefail
10+
11+
main() {
12+
13+
if is_openshift_CI_rehearse_PR; then
14+
echo "Skipping on openshift/release rehearsal PRs"
15+
exit 0
16+
fi
17+
18+
openshift_ci_import_creds
19+
20+
gitbot(){
21+
git -c "user.name=RoxBot" -c "user.email=roxbot@stackrox.com" \
22+
-c "url.https://${GITHUB_TOKEN}:x-oauth-basic@github.com/.insteadOf=https://github.com/" \
23+
"${@}"
24+
}
25+
26+
gitbot -C /tmp clone https://github.com/stackrox/stackrox.git
27+
28+
cd /tmp/stackrox || {
29+
die "Cannot use working clone"
30+
}
31+
32+
gitbot checkout nightlies || {
33+
die "Could not switch to the nightly branch"
34+
}
35+
36+
gitbot rebase master || {
37+
die "Could not rebase"
38+
}
39+
40+
[[ "$(gitbot log --oneline | head -1)" =~ an.empty.commit.for.prow.CI ]] || {
41+
gitbot commit --allow-empty -m 'an empty commit for prow CI'
42+
}
43+
44+
# Create a fresh commit for prow to notice
45+
46+
gitbot reset --hard HEAD~1 || {
47+
die "Could not delete the existing empty commit"
48+
}
49+
50+
gitbot commit --allow-empty -m 'an empty commit for prow CI' || {
51+
die "Could not create an empty commit"
52+
}
53+
54+
# Tag it
55+
56+
local nightly_tag
57+
nightly_tag="$(gitbot describe --tags --abbrev=0 --exclude '*-nightly-*')-nightly-$(date '+%Y%m%d')"
58+
59+
# Allow reruns
60+
(gitbot tag -d "$nightly_tag" && gitbot push --delete origin "$nightly_tag") || true
61+
62+
gitbot tag "$nightly_tag" || {
63+
die "Could not create the tag: $nightly_tag"
64+
}
65+
66+
# Push
67+
68+
gitbot push origin "$nightly_tag" || {
69+
die "Could not push"
70+
}
71+
72+
gitbot push --force || {
73+
die "Could not push"
74+
}
75+
}
76+
77+
main "$@"

0 commit comments

Comments
 (0)