generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get random region for Gardener cluster in backend switching job and c…
…heck for is-PR-approved (#420) * get random region for Gardener cluster in backend switching job * added check for is PR approved for backend switching job
- Loading branch information
Showing
6 changed files
with
97 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script returns a random AWS region name for Gardener cluster. | ||
# Usage: No parameters are required to run this script. Simply call this script to get the region name. | ||
|
||
source "$(pwd)/scripts/utils/utils.sh" | ||
|
||
# standard bash error handling | ||
set -o nounset # treat unset variables as an error and exit immediately. | ||
set -E # needs to be set if we want the ERR trap. | ||
set -o pipefail # prevents errors in a pipeline from being masked. | ||
set -o errexit # exit immediately when a command fails. | ||
|
||
# only lists the regions where machine type: `c1.xlarge` is available. | ||
AWS_REGIONS=( | ||
"eu-west-1" | ||
"us-east-1" | ||
"us-west-1" | ||
"us-west-2" | ||
"sa-east-1" | ||
"ap-northeast-1" | ||
) | ||
|
||
## MAIN Logic | ||
# NOTE: This script should only echo the result. | ||
RAND_INDEX=$(utils::generate_random_number 0 $(( ${#AWS_REGIONS[@]} - 1 ))) | ||
# print the random region name | ||
echo ${AWS_REGIONS[$RAND_INDEX]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script will check if a PR is approved or not. | ||
# Usage: To run this script, provide the following environment variable(s) and run this script. | ||
# - PR_URL - (example: https://github.com/kyma-project/eventing-manager/pull/123) | ||
|
||
# standard bash error handling | ||
set -o nounset # treat unset variables as an error and exit immediately. | ||
set -E # needs to be set if we want the ERR trap. | ||
set -o pipefail # prevents errors in a pipeline from being masked. | ||
set -o errexit # exit immediately when a command fails. | ||
|
||
## MAIN Logic | ||
echo "Checking approval status of : ${PR_URL}" | ||
REVIEW_DECISION=$(gh pr view ${PR_URL} --json=reviewDecision | jq -r '.reviewDecision') | ||
|
||
echo "REVIEW_DECISION: ${REVIEW_DECISION}" | ||
if [[ ${REVIEW_DECISION} == "APPROVED" ]]; then | ||
echo "Pull request is approved!" | ||
exit 0 | ||
fi | ||
|
||
echo "Error: Pull request is not approved!" | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters