Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 30 additions & 18 deletions services/auto-scan/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,40 @@ steps:
args: ["-c", "pip3 install -r requirements.txt && python3 -m pytest"]

- name: 'gcr.io/cloud-builders/docker'
id: build-auto-scan-if-master
id: generate-image-name
entrypoint: 'bash'
dir: services/auto-scan
args:
- '-c'
- |
if [[ "$BRANCH_NAME" == "master" ]]
then
docker build -t gcr.io/$PROJECT_ID/services/autoscan:$BRANCH_NAME-$SHORT_SHA .
else
exit 0
fi
- '-c'
- |
echo "gcr.io/$PROJECT_ID/services/autoscan:$BRANCH_NAME-$SHORT_SHA-$(date +%s)" > /workspace/imagename

- name: 'gcr.io/cloud-builders/docker'
id: push-auto-scan-if-master
id: build-if-master
entrypoint: 'bash'
dir: services/auto-scan
args:
- '-c'
- |
if [[ "$BRANCH_NAME" == "master" ]]
then
image=$(cat /workspace/imagename)
docker build -t $image .
else
exit 0
fi

- name: 'gcr.io/cloud-builders/docker'
id: push-if-master
entrypoint: 'bash'
dir: services/auto-scan
args:
- '-c'
- |
if [[ "$BRANCH_NAME" == "master" ]]
then
docker push gcr.io/$PROJECT_ID/services/autoscan:$BRANCH_NAME-$SHORT_SHA
else
exit 0
fi
- '-c'
- |
if [[ "$BRANCH_NAME" == "master" ]]
then
image=$(cat /workspace/imagename)
docker push $image
else
exit 0
fi