Skip to content

Commit

Permalink
Merge pull request #170 from pwei1018/main
Browse files Browse the repository at this point in the history
Fixed deploy target issue.
  • Loading branch information
pwei1018 authored Jul 16, 2024
2 parents 1917a22 + b0382df commit 59efa9d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
8 changes: 6 additions & 2 deletions .github/actions/backend-deploy-job/files/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ steps:
script: |
#!/usr/bin/env bash
PROJECT_ID=$(cat /workspace/project_id.txt)
PROJECT_NAME=$(echo $PROJECT_ID | cut -d'-' -f 1)
TARGE_ENV=${PROJECT_NAME}-${_DEPLOY_TARGET}
# tag image
gcloud artifacts docker tags add \
${_REGION}-docker.pkg.dev/${_DEPLOY_RUNNING_PROJECT_ID}/cloud-run-repo/${_APP_NAME}:$_SHORT_SHA \
Expand All @@ -78,7 +82,7 @@ steps:
gcloud deploy releases create v-$_SHORT_SHA-${RELEASE_TIMESTAMP} \
--delivery-pipeline=${_DEPLOY_PIPELINE} \
--region=${_REGION} \
--to-target=${_DEPLOY_TARGET} \
--to-target=${TARGE_ENV} \
--images=image-placeholder=${_REGION}-docker.pkg.dev/${_DEPLOY_RUNNING_PROJECT_ID}/cloud-run-repo/${_APP_NAME}:$_SHORT_SHA
else
# prompt the existing release
Expand All @@ -94,7 +98,7 @@ steps:
gcloud deploy releases promote --release=${LATEST_RELEASE_NAME} \
--delivery-pipeline=${_DEPLOY_PIPELINE}\
--region=${_REGION} \
--to-target=${_DEPLOY_TARGET}
--to-target=${TARGE_ENV}
fi
# handle multiple jobs
Expand Down
12 changes: 9 additions & 3 deletions .github/actions/backend-deploy/files/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ steps:
script: |
#!/usr/bin/env bash
PROJECT_NAME=$(op read -n op://CD/${_DEPLOY_TARGET}/${_APP_NAME}/DEPLOY_PROJECT_ID | cut -d'-' -f 1)
PROJECT_ID=$(op read -n op://CD/${_DEPLOY_TARGET}/${_APP_NAME}/DEPLOY_PROJECT_ID)
echo $PROJECT_ID > /workspace/project_id.txt
PROJECT_NAME=$(echo $PROJECT_ID | cut -d'-' -f 1)
targets=(${_DEPLOY_TARGETS})
if [ -z ${_DEPLOY_TARGET_FROM} ] || [ ${_DEPLOY_TARGET_FROM} = ${targets[0]} ]; then
Expand Down Expand Up @@ -75,6 +77,10 @@ steps:
script: |
#!/usr/bin/env bash
PROJECT_ID=$(cat /workspace/project_id.txt)
PROJECT_NAME=$(echo $PROJECT_ID | cut -d'-' -f 1)
TARGE_ENV=${PROJECT_NAME}-${_DEPLOY_TARGET}
# tag image
gcloud artifacts docker tags add \
${_REGION}-docker.pkg.dev/${_DEPLOY_RUNNING_PROJECT_ID}/cloud-run-repo/${_APP_NAME}:$_SHORT_SHA \
Expand All @@ -88,7 +94,7 @@ steps:
gcloud deploy releases create v-${_APP_NAME}-${_SHORT_SHA}-${RELEASE_TIMESTAMP} \
--delivery-pipeline=${_DEPLOY_PIPELINE} \
--region=${_REGION} \
--to-target=${_DEPLOY_TARGET} \
--to-target=${TARGE_ENV} \
--images=image-placeholder=${_REGION}-docker.pkg.dev/${_DEPLOY_RUNNING_PROJECT_ID}/cloud-run-repo/${_APP_NAME}:$_SHORT_SHA
else
# prompt the existing release
Expand All @@ -104,7 +110,7 @@ steps:
gcloud deploy releases promote --release=${LATEST_RELEASE_NAME} \
--delivery-pipeline=${_DEPLOY_PIPELINE}\
--region=${_REGION} \
--to-target=${_DEPLOY_TARGET}
--to-target=${TARGE_ENV}
fi
availableSecrets:
Expand Down

0 comments on commit 59efa9d

Please sign in to comment.