Schedule a nightly CI pipeline against each PR

- don't report to Slack if SLACK_WEBHOOK_URL is not defined
- report GitHub statuses separately for regular pipeline & nightly
  pipeline
This commit is contained in:
Alexander Todorov 2023-07-03 12:35:19 +03:00 committed by Ondřej Budai
parent d7ed3cae6e
commit 7fa81a514f
3 changed files with 28 additions and 7 deletions

View file

@ -1,11 +1,5 @@
#!/bin/bash
# Don't overwrite CI statuses on GitHub branches for nightly pipelines
if [[ "$CI_PIPELINE_SOURCE" == "schedule" ]]; then
exit 0
fi
# if a user is logged in to the runner, wait until they're done
while (( $(who -s | wc -l) > 0 )); do
echo "Waiting for user(s) to log off"
@ -33,12 +27,17 @@ else
exit 1
fi
CONTEXT="Schutzbot on GitLab"
if [[ "$CI_PIPELINE_SOURCE" == "schedule" ]]; then
CONTEXT="$CONTEXT, RHEL-${RHEL_MAJOR:-}-nightly"
fi
curl \
-u "${SCHUTZBOT_LOGIN}" \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/osbuild/osbuild-composer/statuses/${CI_COMMIT_SHA}" \
-d '{"state":"'"${GITHUB_NEW_STATE}"'", "description": "'"${GITHUB_NEW_DESC}"'", "context": "Schutzbot on GitLab", "target_url": "'"${CI_PIPELINE_URL}"'"}'
-d '{"state":"'"${GITHUB_NEW_STATE}"'", "description": "'"${GITHUB_NEW_DESC}"'", "context": "'"${CONTEXT}"'", "target_url": "'"${CI_PIPELINE_URL}"'"}'
# ff release branch on github if this ran on main
if [ "$CI_COMMIT_BRANCH" = "main" ] && [ "$GITHUB_NEW_STATE" = "success" ]; then