Skip to content

Commit

Permalink
cleanup: merge v2-sql branch into main (#122)
Browse files Browse the repository at this point in the history
* improvement: add mysql support for the inventory service (#89)

* fix: remove incorrect delimiter in skaffold

* ci: add skaffold build step

* fix: namespace error in cloudbuild

* fix: the cloudbuild config for gcloud

* fix: the pr number prefix

* cleanup: use kubectl image

* cleanup: format cloudbuild file

* fix: pr prefix

* fix: change underscore to hyphen

* cleanup: update kubectl image in skaffold builder

* fix: kubectl command

* cleanup: add correct node version tag

* cleanup: update namepsace yaml creation

* cleanup: update the skaffold image usage

* cleanup: split the gcloud command

* cleanup: fix extra quotes

* fix: split the cloudbuild step commands

* cleanup: move gcloud and skaffold into a file

* cleanup: split the exec command

* fix: add skaffold build and deploy steps

* cleanup: add timeout to build

* cleanup: remove unused image

* cleanup: remove unused file

* process: add options related t custom sa

* cleanup: write logs to bucket

* test: trigger ci

* test: trigger ci

* cleanup: remove unnecessary skaffold steps

* cleanup:migrate to new project

* cleanup:migrate to new project

* test: check builds

* test: check builds

* test: check builds

* ci: add cleanup step

* ci: fix merge commits

* ci: add steps to deploy main to staging

* test: check builds

* ci: split the deploy steps

* test: check builds

* test: check builds

* test: check builds

* ci: remove the maven clean

* ci: fix repo name

* ci: fix repo name

* ci: comment the artifact maven plugin

* ci: add mvn clean step before skaffold

* ci: run the maven wrapper

* ci run the mvnw first

* ci: remove mvnw

* ci: remove mvnw

* ci: make mvnw executable

* ci: add mvnw back

* ci: add mvnw to the merge to pr step

* doc: minor fix (#87)

* doc: test pr (#88)

* doc: minor fix

* test: check builds

* test: check builds

* fix: remove maven clean

* fix: remove maven clean

* ci: remove initial mvn install

* test: check builds

* cleanup: change master to main

* improvement: add db access layer to the inventory service

* improvement: complete mysql to inventory service

* ci: add license header

* fix: skip datasource loading with payments and apiserver

* fix: explude JDBC in tests

* cleanup: remove the exclusion rule in test

* fix: NPE

* test: check builds

* test: exclude hibernate

* add: spring profiles and h2 db

* improvement: add mysql manifest

* improvement: split skaffold with profiles

* doc: add readme

* fix: update the skaffold commands

* lint: remove unnecessary extra line

* cleanup: add region tags

* cleanup: add profiles for db

* config: fix skaffold ot point to correct repo for mysql

* config: move build to the dev profile

* fix: skaffold error with 3p images

* ci: add inmemory profile to the pr cloudbuild yaml

* ci: add deployment type suffix to tag

* cleanup: fix region tags

* ci: update cleanup and staging ci yamls

* ci: increase timeout

* doc: add details for inmemory profile

* improvement: add mysql payments (#90)

* fix: remove incorrect delimiter in skaffold

* ci: add skaffold build step

* fix: namespace error in cloudbuild

* fix: the cloudbuild config for gcloud

* fix: the pr number prefix

* cleanup: use kubectl image

* cleanup: format cloudbuild file

* fix: pr prefix

* fix: change underscore to hyphen

* cleanup: update kubectl image in skaffold builder

* fix: kubectl command

* cleanup: add correct node version tag

* cleanup: update namepsace yaml creation

* cleanup: update the skaffold image usage

* cleanup: split the gcloud command

* cleanup: fix extra quotes

* fix: split the cloudbuild step commands

* cleanup: move gcloud and skaffold into a file

* cleanup: split the exec command

* fix: add skaffold build and deploy steps

* cleanup: add timeout to build

* cleanup: remove unused image

* cleanup: remove unused file

* process: add options related t custom sa

* cleanup: write logs to bucket

* test: trigger ci

* test: trigger ci

* cleanup: remove unnecessary skaffold steps

* cleanup:migrate to new project

* cleanup:migrate to new project

* test: check builds

* test: check builds

* test: check builds

* ci: add cleanup step

* ci: fix merge commits

* ci: add steps to deploy main to staging

* test: check builds

* ci: split the deploy steps

* test: check builds

* test: check builds

* test: check builds

* ci: remove the maven clean

* ci: fix repo name

* ci: fix repo name

* ci: comment the artifact maven plugin

* ci: add mvn clean step before skaffold

* ci: run the maven wrapper

* ci run the mvnw first

* ci: remove mvnw

* ci: remove mvnw

* ci: make mvnw executable

* ci: add mvnw back

* ci: add mvnw to the merge to pr step

* doc: minor fix (#87)

* doc: test pr (#88)

* doc: minor fix

* test: check builds

* test: check builds

* fix: remove maven clean

* fix: remove maven clean

* ci: remove initial mvn install

* test: check builds

* cleanup: change master to main

* improvement: add db access layer to the inventory service

* improvement: complete mysql to inventory service

* ci: add license header

* improvement: add mysql to payments

* improvement: add db stuff to payments service

* lint: add header

* fix: skip datasource loading with payments and apiserver

* fix: explude JDBC in tests

* cleanup: remove the exclusion rule in test

* fix: NPE

* test: check builds

* test: exclude hibernate

* add: spring profiles and h2 db

* improvement: add mysql manifest

* improvement: split skaffold with profiles

* doc: add readme

* fix: update the skaffold commands

* lint: remove unnecessary extra line

* cleanup: add region tags

* cleanup: point to new project ci

* cleanup: remove command activation in skaffold

* ci: fix the skaffold profile definintion

* skaffold: add snapshot tag until first release

* doc: add comment with the link to the builder

* cleanup: add profiles for db

* config: fix skaffold ot point to correct repo for mysql

* config: move build to the dev profile

* fix: skaffold error with 3p images

* ci: add inmemory profile to the pr cloudbuild yaml

* ci: add deployment type suffix to tag

* cleanup: fix region tags

* ci: update cleanup and staging ci yamls

* ci: increase timeout

* ci: add encrypted token

* fix: cloudbuild yaml for gh token

* fix: remove linebreak

* fix: remove linebreak

* test: check builds

* ci: format

* fix: gh command

* cleanup: update app.properties for payments

* fix: quotation issue in jsonpath

* ci: split Ip fetching to a script

* ci: update the image for the github ci

* cleanup: remove the inmemory payment impl

* ci: fix the comment step in the build

* ci: fix the substitution variable rrors

* cleanup: remove unused class

* cleanup: remove ref to deleted class

* ci: add markdown syntax for URL

* fix: invalid import statement

* fix: removed fields during merge

* cldeanup: remove extra space

* test: check builds

* ci: update the gh comment

* test: check builds

* fix: error with the incorrect annotation

* cleanup: remove unnecessary annotations

* fix: mysql warning (#110)

* doc: restructure directories and add quickstart (#115)

* doc: restructure

* doc: fix region tag

* doc: fix region tags

* cleanup: update the skaffold file

* cleanup: add project suffix to the pom

* cleanup: fix path error in cloudbuild yaml

* fix: update the cloudbuild yamls

* cleanup: add the mvnwrapper

* lint: add correct license year

* fix: update the header

* fix: clpoudbuil yaml

* ci: add dir for deploy step

* ci: revert cloudbuild changes

* test: find directory

* test: find directory

* test: find directory

* cleanup: move maven wrapper to the root

* cleanup: add relativePath to parent pom

* cleanup: update the push to main yaml

* fix: the path issue in the apiserver pom

* cleanup: revert changes inside the point-of-sale-app folder to match main (#116)

* doc: restructure

* doc: fix region tag

* doc: fix region tags

* cleanup: update the skaffold file

* cleanup: add project suffix to the pom

* cleanup: fix path error in cloudbuild yaml

* fix: update the cloudbuild yamls

* cleanup: add the mvnwrapper

* lint: add correct license year

* fix: update the header

* fix: clpoudbuil yaml

* ci: add dir for deploy step

* ci: revert cloudbuild changes

* cleanup: maintain point-of-sale-app folder as is in main

* header: fix year

* cleanup: remove and add

* fix: header check error

* test: find directory

* test: find directory

* test: find directory

* cleanup: move maven wrapper to the root

* cleanup: add relativePath to parent pom

* cleanup: update the push to main yaml

* improvement: add release automation files (#119)

* doc: restructure

* doc: fix region tag

* doc: fix region tags

* cleanup: update the skaffold file

* cleanup: add project suffix to the pom

* cleanup: fix path error in cloudbuild yaml

* fix: update the cloudbuild yamls

* cleanup: add the mvnwrapper

* lint: add correct license year

* fix: update the header

* fix: clpoudbuil yaml

* ci: add dir for deploy step

* ci: revert cloudbuild changes

* cleanup: maintain point-of-sale-app folder as is in main

* header: fix year

* cleanup: remove and add

* fix: header check error

* test: find directory

* test: find directory

* test: find directory

* cleanup: move maven wrapper to the root

* cleanup: add relativePath to parent pom

* cleanup: update the push to main yaml

* fix: the path issue in the apiserver pom

* release: add initial releaser code

* release: fix str error

* cleanup: get xml parser working

* cleanuP: fix pom linting

* cleanup: add extra linebreak

* fix: merge conflict

* cleanup: linting in ui pom

* improvement: add logic to update package.json

* lint: reformat the pom

* lint: remove extra space

* chore(release): 0.1.0-SNAPSHOT

* Revert "chore(release): 0.1.0-SNAPSHOT"

This reverts commit 8f3fae2.

* chore(release): 0.1.0-SNAPSHOT

* Revert "chore(release): 0.1.0-SNAPSHOT"

This reverts commit fdb238f.

* cleanup: add changlog packagejson

* fix: add code to update release pkg json

* fix: indent on pkf json

* fix: indent on pkf json

* process: add release trigger

* fix: escape env subs

* chore: add branch name

* chore: add pip install step

* chore: add git branch

* chore: add remote

* test: show remote

* test: show remote

* test: show remote

* test: show remote

* test: show remote

* test: show remote

* release: update version before release

* Revert "release: update version before release"

This reverts commit 00e36d9.

* cleanup: remove username from git

* test: show remote

* test: set branch

* test: set branch

* test: set branch

* test: set branch

* test: set branch

* test: set branch

* release: update version before release

* Revert "release: update version before release"

This reverts commit db838c5.

* test: set branch

* release: update version before release

* cleanup: add clarifying comment

* Revert "release: update version before release"

This reverts commit c6590f6.

* chore: set github email secret

* release: update version before release

* Revert "release: update version before release"

This reverts commit f2649c4.

* release: update version before release

* chore: add publish yaml

* Revert "release: update version before release"

This reverts commit ff14e7f.

* release: update version before release

* Revert "release: update version before release"

This reverts commit 110a1bc.

* chore: add build step for deploying images

* chore: add python step to publish yaml

* chore: update releaser to print version

* chore: rearrange code

* release: update version before release

* chore: fix version error

* Revert "release: update version before release"

This reverts commit 550eb9c.

* release: update version before release

* Revert "release: update version before release"

This reverts commit 65bd83f.

* chore: fix substution variable

* release: update version before release

* Revert "release: update version before release"

This reverts commit 3fe4f54.

* chore: fix the version and deps

* release: update version before release

* Revert "release: update version before release"

This reverts commit ec7b888.

* chore: fix the version and deps

* release: update version before release

* Revert "release: update version before release"

This reverts commit abbdbd4.

* chore: fix the version and deps

* release: update version before release

* Revert "release: update version before release"

This reverts commit ececb4d.

* chore: fix the version and deps

* release: update version before release

* Revert "release: update version before release"

This reverts commit 4208bd6.

* chore: fix the version and deps

* release: update version before release

* Revert "release: update version before release"

This reverts commit 9642318.

* chore: fix the version and deps

* release: update version before release

* Revert "release: update version before release"

This reverts commit 9aebc49.

* chore: fix the version and deps

* release: update version before release

* Revert "release: update version before release"

This reverts commit 0039752.

* cleanup: rearrange yamls

* improv: add yaml update logic

* chore: add logic to update all yamls

* chore: add new lines

* chore: reorder the updates

* release: update version before release

* chore: updated release script

* chore: uncomment the file edit

* chore: rearrange the prints

* chore: add new argument

* chore: update the releaser to take patch as the next release version

* chore: add logic to set SNAPSHOT version

* chore: fix incorrect variable bug

* chore: fix releaser release versioning

* chore: update release yaml files

* chore: complete the release yamls

* chore: save merge conflict resolution

* chore: set root pom to SNAPSHOT

* chore: fix bash error

* release: update version before release

* chore: update commit msg checks

* chore: add formatting

* Revert "release: update version before release"

This reverts commit 7d5aad9.

* release: update version before release

* chore: fix versions

* chore: fix commit message

* release: update version before release

* chore: fix formatting

* Revert "release: update version before release"

This reverts commit 20f362a.

* chore: add email token to build file

* release: update version before release

* Revert "release: update version before release"

This reverts commit ee086cc.

* chore add deploy script

* chore: fix branch error

* release: update version before release

* release: update version before release

* release: update version before release

* Revert "release: update version before release"

This reverts commit 4473cb5.

* chore: fix version.txt error

* chore: fix deploy ci

* chore: update print message

* chore: enhance comment message

* chore(release): 0.1.0

* chore(release): 0.1.1

* chore: fix comment msg

* chore: remove mvn install

* chore: reorganize the deploy yaml

* chore: add gh release step

* chore: rename common service fiel names

* chore: update the skaffold file to have services

* chore: fix region tag

* chore: force

* chore: fix bash err

* release: update version before release

* release: bump version to next snapshot

* chore: update release messafe

* Revert "release: bump version to next snapshot"

This reverts commit 7f54c9a.

* Revert "release: update version before release"

This reverts commit e57bfdf.

* chore: add readme for release

* doc: improve release doc

* doc: add more release steps

* doc: add more release steps

* doc: add more release steps

* doc: add more release steps

* doc: add more release steps

* doc: add more release steps

* doc: add more release steps

* chore: remove branch ref

* chore: update the README

* chore: rename relese yaml

* doc: add release link to the main README

* doc: update doc size

* doc: add note to click to enlarge

* doc: note about Googler release

* doc: fix hyperlonk
  • Loading branch information
Shabirmean committed May 10, 2022
1 parent 05be48e commit 44237de
Show file tree
Hide file tree
Showing 116 changed files with 22,986 additions and 44 deletions.
156 changes: 156 additions & 0 deletions .github/cloudbuild/pos-check-for-release.yaml
@@ -0,0 +1,156 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

###########################################################
# This is a GCP CloudBuild Trigger config file. The trigger
# is for when a PR is open from a branch named release-x.
# x can be major, minor, or patch.
###########################################################

steps:
###########################################################
# Gating step to ensure we run it only once
###########################################################
- id: 'gate-ci'
name: 'python'
entrypoint: bash
args:
- -c
- |
touch /workspace/release.done
COMMIT_MSG=$(git log -1 --oneline --format=%s | sed 's/^.*: //')
if [[ $$COMMIT_MSG == 'update version before release' ]] || [[ $$COMMIT_MSG == 'bump version to next snapshot' ]]; then
echo "Commit message [$$COMMIT_MSG] indicates release version already being updated. Skip steps."
echo "RELEASE_COMPLETE" > /workspace/release.done
fi
# indicates that the step need not wait for any other step
waitFor: [ '-' ]

###########################################################
# Version bump on release PR
###########################################################
- id: 'bump-version'
name: 'python'
entrypoint: bash
args:
- -c
- |
STATUS=$(cat /workspace/release.done)
if [[ $$STATUS == 'RELEASE_COMPLETE' ]]; then
exit 0
fi
pip install -r .github/releases/requirements.txt
echo "PR openned on branch [$_HEAD_BRANCH] for pr-$_PR_NUMBER"
if [[ $_HEAD_BRANCH == 'release-minor' ]]; then
echo "Updating versions for a minor release"
python3 .github/releases/releaser.py -t minor
elif [[ $_HEAD_BRANCH == 'release-patch' ]]; then
echo "Updating versions for a patch release"
python3 .github/releases/releaser.py -t patch
elif [[ $_HEAD_BRANCH == 'release-major' ]]; then
echo "Updating versions for a major release"
python3 .github/releases/releaser.py -t major
else
echo "Nothing to do since it's not a 'release' PR"
echo "RELEASE_COMPLETE" > /workspace/release.done
fi
VERSION=$(python3 .github/releases/releaser.py -p true)
echo "$$VERSION" > release-version.txt
# indicates that the step need not wait for any other step
waitFor: [ 'gate-ci' ]

###########################################################
# Push the version changes to the repo
###########################################################
- id: 'push-changes-to-repo'
name: 'gcr.io/cloud-builders/git'
secretEnv: [ 'GITHUB_TOKEN', 'GITHUB_EMAIL' ]
entrypoint: bash
args:
- -c
- |
STATUS=$(cat /workspace/release.done)
if [[ $$STATUS == 'RELEASE_COMPLETE' ]]; then
exit 0
fi
# we do this so that the deploy triggers can know the PR number
echo "$_PR_NUMBER" > release-pr.number
git config user.email "$$GITHUB_EMAIL"
git config user.name "Anthos DPE"
# as per: https://stackoverflow.com/a/67886960/3396045
git remote set-branches --add origin $_HEAD_BRANCH
git fetch 'origin'
git checkout --track origin/$_HEAD_BRANCH
git add -A
git commit -m "release: update version before release"
git push -u https://$$GITHUB_TOKEN@github.com/GoogleCloudPlatform/point-of-sale.git $_HEAD_BRANCH
waitFor: [ 'bump-version' ]

###########################################################
# Comment about the release status on the release PR
###########################################################
- id: 'comment-release-status-to-github'
name: 'us-docker.pkg.dev/point-of-sale-ci/third-party-images/github-cli:mar-22'
secretEnv: [ 'GITHUB_TOKEN' ]
entrypoint: bash
args:
- -c
- |
STATUS=$(cat /workspace/release.done)
if [[ $$STATUS == 'RELEASE_COMPLETE' ]]; then
exit 0
fi
COMMIT_MSG=$(git log -1 --oneline --format=%s | sed 's/^.*: //')
if [[ $$COMMIT_MSG != 'update version before release' ]]; then
echo "Commit message [$$COMMIT_MSG] is not a release commit. Skipping step."
exit 0
fi
RELEASE_TYPE='patch'
if [[ $_HEAD_BRANCH == 'release-minor' ]]; then
RELEASE_TYPE='minor'
elif [[ $_HEAD_BRANCH == 'release-major' ]]; then
RELEASE_TYPE='major'
fi
LAST_COMMIT=$(cat .git/refs/heads/$_HEAD_BRANCH)
cat <<EOF > /workspace/gh-comment.txt -
:zap: Release Status :zap: </br>
- **Version updated**: Version in the `pom.xml/package.json` has been updated to the next **$$RELEASE_TYPE** release version.
- **Publish Artifacts:** Check the most recent commit ($$LAST_COMMIT) for correctness and run the ["pos-publish-release-artifacts"](https://console.cloud.google.com/cloud-build/triggers;region=global?project=point-of-sale-ci) trigger against this branch **[$BRANCH_NAME]** to upload the artifacts _(Jars and Images)_ to Artifact registry.
EOF
gh pr comment $_PR_NUMBER --repo $_HEAD_REPO_URL --body-file /workspace/gh-comment.txt
# waitFor: commented out, so this step waits for all previous steps

availableSecrets:
inline:
- kmsKeyName: 'projects/$PROJECT_ID/locations/global/keyRings/$_GHTOKEN_KEYRING_NAME/cryptoKeys/$_GHTOKEN_KEY_NAME'
envMap:
GITHUB_TOKEN: 'CiQAuVI6Z93rj1B1R4yer3G1VzEmW7aHtjATP2jOtyJjkW5qOR8SUQBHWet7zXRDJQTBSvFZuXXsOBIxtvf0VDM610Tjgb5XJY8hbIuBxhsMfDy3+/p2ojVnYmE+Mg9NDg5FGZhlJlB/+PBMCumkbMovTXD582u17A=='
- kmsKeyName: 'projects/$PROJECT_ID/locations/global/keyRings/$_GHEMAIL_KEYRING_NAME/cryptoKeys/$_GHEMAIL_KEY_NAME'
envMap:
GITHUB_EMAIL: 'CiQA/ThyQ4p/sDUR2fsc4Q2GgF/PntA048keplEhVQTrmgESLfcSOACXDXFpPP/ASB9nwBao91OK4677dEaGsJQjVKkStDpHtY1ZtF7qefjxq1qK93BSezLllJX/rHbY'
logsBucket: 'gs://pos-cloudbuild-logs'
options:
logging: GCS_ONLY
45 changes: 45 additions & 0 deletions .github/cloudbuild/pos-deploy-release.yaml
@@ -0,0 +1,45 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

###########################################################
# This is a GCP CloudBuild Trigger config file. The trigger
# is to be used to build and publish the latest release
# artifacts to repostiories (container-image and maven).
# The trigger associated to this cloudbuild confiuration
# needs to be manually RUN pointing to the release-branch
###########################################################

steps:
###########################################################
# Deploy the latest release manifests to the main cluster
###########################################################
- id: 'deploy-to-k8s-main'
name: 'gcr.io/k8s-skaffold/skaffold:v1.36.0'
entrypoint: bash
args:
- -c
- |
gcloud container clusters get-credentials --zone $_MAIN_CLUSTER_ZONE $_MAIN_CLUSTER
kubectl create namespace $_MAIN_NS-db
kubectl create namespace $_MAIN_NS-inmemory
kubectl apply -f /workspace/namespace.yaml
skaffold run -p release -f=skaffold.yaml --namespace=$_MAIN_NS-db
skaffold run -p release,inmemory -f=skaffold.yaml --namespace=$_MAIN_NS-inmemory
# waitFor: commented out, so this step waits for all previous steps

timeout: 1800s
logsBucket: 'gs://pos-cloudbuild-logs'
options:
logging: GCS_ONLY
30 changes: 22 additions & 8 deletions .github/cloudbuild/pos-pr-open-to-main.yaml
Expand Up @@ -23,7 +23,7 @@ steps:
###########################################################
- id: 'npm-install'
name: 'node:16.14.0'
dir: 'point-of-sale-app/ui'
dir: 'src/ui'
entrypoint: 'npm'
args: [ 'install' ]
# indicates that the step need not wait for any other step
Expand All @@ -39,10 +39,17 @@ steps:
- -c
- |
cat <<EOF > /workspace/namespace.yaml -
# namespace to deploy the mysql db based deployment
apiVersion: v1
kind: Namespace
metadata:
name: pr-$_PR_NUMBER
name: pr-$_PR_NUMBER-db
---
# namespace to deploy the inmemory h2 db based deployment
apiVersion: v1
kind: Namespace
metadata:
name: pr-$_PR_NUMBER-inmemory
EOF
# indicates that the step need not wait for any other step
waitFor: [ '-' ]
Expand Down Expand Up @@ -79,7 +86,8 @@ steps:
gcloud container clusters get-credentials --zone $_DEV_CLUSTER_ZONE $_DEV_CLUSTER
./mvnw install
skaffold run -p dev -f=skaffold.yaml --default-repo=us-docker.pkg.dev/$PROJECT_ID/$_POS_IMAGE_REPO --namespace=pr-$_PR_NUMBER --tag=pr-$_PR_NUMBER
skaffold run -p dev -f=skaffold.yaml --default-repo=us-docker.pkg.dev/$PROJECT_ID/$_POS_IMAGE_REPO --namespace=pr-$_PR_NUMBER-db --tag=pr-$_PR_NUMBER-db
skaffold run -p dev,inmemory -f=skaffold.yaml --default-repo=us-docker.pkg.dev/$PROJECT_ID/$_POS_IMAGE_REPO --namespace=pr-$_PR_NUMBER-inmemory --tag=pr-$_PR_NUMBER-inmemory
EOF
# indicates that the step need not wait for any other step
Expand All @@ -90,7 +98,6 @@ steps:
###########################################################
- id: 'deploy-to-k8s'
name: 'gcr.io/k8s-skaffold/skaffold:v1.36.0'
dir: 'point-of-sale-app'
args: [
'bash',
'/workspace/deploy.sh',
Expand All @@ -107,8 +114,10 @@ steps:
- -c
- |
gcloud container clusters get-credentials --zone $_DEV_CLUSTER_ZONE $_DEV_CLUSTER
kubectl -n pr-$_PR_NUMBER get service/$_LB_SERVICE -o jsonpath='{.status.loadBalancer.ingress[0].ip}' > /workspace/pr-$_PR_NUMBER.ip
echo "External IP [$(cat /workspace/pr-$_PR_NUMBER.ip)] saved to file /workspace/pr-$_PR_NUMBER.ip"
kubectl -n pr-$_PR_NUMBER-db get service/$_LB_SERVICE -o jsonpath='{.status.loadBalancer.ingress[0].ip}' > /workspace/pr-$_PR_NUMBER-db.ip
kubectl -n pr-$_PR_NUMBER-inmemory get service/$_LB_SERVICE -o jsonpath='{.status.loadBalancer.ingress[0].ip}' > /workspace/pr-$_PR_NUMBER-inmemory.ip
echo "External IP [$(cat /workspace/pr-$_PR_NUMBER-db.ip)] saved to file /workspace/pr-$_PR_NUMBER-db.ip"
echo "External IP [$(cat /workspace/pr-$_PR_NUMBER-inmemory.ip)] saved to file /workspace/pr-$_PR_NUMBER-inmemory.ip"
waitFor: [ 'deploy-to-k8s' ]

Expand All @@ -122,15 +131,20 @@ steps:
args:
- -c
- |
gh pr comment $_PR_NUMBER --repo $_HEAD_REPO_URL --body "Access the Point-of-Sale at: [$(cat /workspace/pr-$_PR_NUMBER.ip)](http://$(cat /workspace/pr-$_PR_NUMBER.ip))"
cat <<EOF > /workspace/gh-comment.txt -
:zap: Two deployments have been created for the Point-of-Sale application. You may access and test them at: :zap: </br>
- **MySQL DB** backed deployment: [**$(cat /workspace/pr-$_PR_NUMBER-db.ip)**](http://$(cat /workspace/pr-$_PR_NUMBER-db.ip))
- **Embedded H2** DB backed deployment: [**$(cat /workspace/pr-$_PR_NUMBER-inmemory.ip)**](http://$(cat /workspace/pr-$_PR_NUMBER-inmemory.ip))
EOF
gh pr comment $_PR_NUMBER --repo $_HEAD_REPO_URL --body-file /workspace/gh-comment.txt
waitFor: [ 'get-external-loadbalancer-ip' ]

availableSecrets:
inline:
- kmsKeyName: 'projects/$PROJECT_ID/locations/global/keyRings/$_GHTOKEN_KEYRING_NAME/cryptoKeys/$_GHTOKEN_KEY_NAME'
envMap:
GITHUB_TOKEN: 'CiQAuVI6Z93rj1B1R4yer3G1VzEmW7aHtjATP2jOtyJjkW5qOR8SUQBHWet7zXRDJQTBSvFZuXXsOBIxtvf0VDM610Tjgb5XJY8hbIuBxhsMfDy3+/p2ojVnYmE+Mg9NDg5FGZhlJlB/+PBMCumkbMovTXD582u17A=='
timeout: 900s
timeout: 1800s
logsBucket: 'gs://pos-cloudbuild-logs'
options:
logging: GCS_ONLY
3 changes: 2 additions & 1 deletion .github/cloudbuild/pos-pr-webhook-event.yaml
Expand Up @@ -31,7 +31,8 @@ steps:
echo "Event [$_PULL_REQUEST_EVENT_TYPE] for pr-$_PULL_REQUEST_ID"
if [ $_PULL_REQUEST_EVENT_TYPE == 'closed' ]; then
gcloud container clusters get-credentials --zone $_DEV_CLUSTER_ZONE $_DEV_CLUSTER
kubectl delete namespace pr-$_PULL_REQUEST_ID || true
kubectl delete namespace pr-$_PULL_REQUEST_ID-db
kubectl delete namespace pr-$_PULL_REQUEST_ID-db || true
else
echo "Nothing to do since it's not a 'closed' event"
fi
Expand Down

0 comments on commit 44237de

Please sign in to comment.