-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from CedrickArmel/chore/trigger
chore: cb manual trigger in gha and trigger update
- Loading branch information
Showing
3 changed files
with
70 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Exclure tout par défaut | ||
* | ||
|
||
# Autoriser uniquement les dossiers/fichiers spécifiques | ||
!src/ | ||
!poetry.lock | ||
!pyproject.toml | ||
!conf/base/ | ||
!.env |
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,58 @@ | ||
#!/bin/bash | ||
usage() { | ||
echo "Usage: $0 -p <project> -r <region> -t <trigger> [-b <branch>] [-s <substitutions>]" | ||
exit 1 | ||
} | ||
|
||
while getopts "p:r:t:b:s:" opt; do | ||
case $opt in | ||
p) project="$OPTARG";; | ||
r) region="$OPTARG";; | ||
t) trigger="$OPTARG";; | ||
b) branch="$OPTARG";; | ||
s) substitutions="$OPTARG";; | ||
*) usage;; | ||
esac | ||
done | ||
|
||
# Check if mandatory parameters are provided | ||
if [ -z "$project" ] || [ -z "$region" ] || [ -z "$trigger" ]; then | ||
usage | ||
fi | ||
|
||
export CLOUDSDK_CORE_DISABLE_PROMPTS=1 | ||
|
||
# Set the project | ||
gcloud config set project "$project" | ||
|
||
# Run the gcloud command based on whether the branch and substitutions are provided | ||
if [ -z "$substitutions" ]; then | ||
if [ -z "$branch" ]; then | ||
BUILD_ID=$(gcloud beta builds triggers run "$trigger" --region="$region" --quiet --format="value(metadata.build.id)") | ||
else | ||
BUILD_ID=$(gcloud beta builds triggers run "$trigger" --region="$region" --branch="$branch" --quiet --format="value(metadata.build.id)") | ||
fi | ||
else | ||
if [ -z "$branch" ]; then | ||
BUILD_ID=$(gcloud beta builds triggers run "$trigger" --region="$region" --substitutions="$substitutions" --quiet --format="value(metadata.build.id)") | ||
else | ||
BUILD_ID=$(gcloud beta builds triggers run "$trigger" --region="$region" --substitutions="$substitutions" --branch="$branch" --quiet --format="value(metadata.build.id)") | ||
fi | ||
fi | ||
|
||
# Output the BUILD_ID | ||
echo "BUILD_ID = $BUILD_ID" | ||
|
||
# Stream the logs | ||
gcloud beta builds log --stream "$BUILD_ID" --region="$region" | ||
|
||
# Get the build status | ||
BUILD_STATUS=$(gcloud beta builds describe "$BUILD_ID" --format="value(status)" --region="$region") | ||
echo "Build status = $BUILD_STATUS" | ||
|
||
# Exit based on build status | ||
if [ "$BUILD_STATUS" == "SUCCESS" ]; then | ||
exit 0 | ||
else | ||
exit 1 | ||
fi |