Skip to content

Commit

Permalink
ci/cd:move to new cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratap2018 committed Dec 5, 2024
1 parent 25d0d41 commit bb825f5
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 70 deletions.
28 changes: 14 additions & 14 deletions .deploy/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ spec:
app: kyc-widget
spec:
containers:
- name: kyc-widget
image: __GOOGLE_ARTIFACT_URL__/__GOOGLE_PROJECT_ID__/__GOOGLE_ARTIFACT_REPO__/kyc-widget:__LATEST_RELEASE_TAG__
imagePullPolicy: Always
resources:
limits:
memory: '64Mi'
cpu: '50m'
requests:
memory: '32Mi'
cpu: '25m'
ports:
- containerPort: 4888
- name: kyc-widget
image: __GOOGLE_ARTIFACT_URL__/__GOOGLE_PROJECT_ID__/__GOOGLE_ARTIFACT_REPO__/kyc-widget:__LATEST_RELEASE_TAG__
imagePullPolicy: Always
resources:
limits:
memory: '512Mi'
cpu: '200m'
requests:
memory: '256Mi'
cpu: '100m'
ports:
- containerPort: 4888
---
apiVersion: v1
kind: Service
Expand All @@ -37,5 +37,5 @@ spec:
selector:
app: kyc-widget
ports:
- port: 4888
targetPort: 80
- port: 4888
targetPort: 80
112 changes: 56 additions & 56 deletions .github/workflows/CI_CD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,78 @@ name: KYC widget Build and Deploy
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]-rc.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]-rc.[0-9]+'

jobs:
Build-Pipeline:
runs-on: ubuntu-latest
steps:
- name: code checkout
uses: actions/checkout@v3
- name: code checkout
uses: actions/checkout@v3

- name: Set Latest Tag
run: echo "LATEST_RELEASE_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- id: 'auth'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}'
- name: Set Latest Tag
run: echo "LATEST_RELEASE_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- id: 'auth'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}'

- name: install gcloud cli tools
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{secrets.GOOGLE_PROJECT_ID}}
service_account_key: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}}
install_components: 'gke-gcloud-auth-plugin'
export_default_credentials: true
- name: install gcloud cli tools
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{secrets.GOOGLE_PROJECT_ID}}
service_account_key: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}}
install_components: 'gke-gcloud-auth-plugin'
export_default_credentials: true

- name: 'Use gcloud CLI'
run: 'gcloud info'
- name: 'Use gcloud CLI'
run: 'gcloud info'

- name: 'Docker Auth'
run: gcloud auth configure-docker ${{secrets.GOOGLE_ARTIFACT_URL}}
- name: 'Docker Build and Push'
env:
GOOGLE_PROJECT_ID: ${{secrets.GOOGLE_PROJECT_ID}}
GOOGLE_ARTIFACT_URL: ${{secrets.GOOGLE_ARTIFACT_URL}}
GOOGLE_ARTIFACT_REPO: ${{secrets.GOOGLE_ARTIFACT_REPO}}
- name: 'Docker Auth'
run: gcloud auth configure-docker ${{secrets.GOOGLE_ARTIFACT_URL}}
- name: 'Docker Build and Push'
env:
GOOGLE_PROJECT_ID: ${{secrets.GOOGLE_PROJECT_ID}}
GOOGLE_ARTIFACT_URL: ${{secrets.GOOGLE_ARTIFACT_URL}}
GOOGLE_ARTIFACT_REPO: ${{secrets.GOOGLE_ARTIFACT_REPO}}

run: docker build -t $GOOGLE_ARTIFACT_URL/$GOOGLE_PROJECT_ID/$GOOGLE_ARTIFACT_REPO/kyc-widget:${{env.LATEST_RELEASE_TAG}} .
run: docker build -t $GOOGLE_ARTIFACT_URL/$GOOGLE_PROJECT_ID/$GOOGLE_ARTIFACT_REPO/kyc-widget:${{env.LATEST_RELEASE_TAG}} .

docker push $GOOGLE_ARTIFACT_URL/$GOOGLE_PROJECT_ID/$GOOGLE_ARTIFACT_REPO/kyc-widget:${{env.LATEST_RELEASE_TAG}}
docker push $GOOGLE_ARTIFACT_URL/$GOOGLE_PROJECT_ID/$GOOGLE_ARTIFACT_REPO/kyc-widget:${{env.LATEST_RELEASE_TAG}}
Deploy-Pipeline:
needs: [Build-Pipeline]
needs: [ Build-Pipeline ]
runs-on: ubuntu-latest
steps:
- name: code checkout
uses: actions/checkout@v3
- name: code checkout
uses: actions/checkout@v3

- name: Set Latest Tag
run: echo "LATEST_RELEASE_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- id: 'auth'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}'
- name: Set Latest Tag
run: echo "LATEST_RELEASE_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- id: 'auth'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}'

- name: install gcloud cli tools
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{secrets.GOOGLE_PROJECT_ID}}
service_account_key: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}}
install_components: 'gke-gcloud-auth-plugin'
export_default_credentials: true
- name: install gcloud cli tools
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{secrets.GOOGLE_PROJECT_ID}}
service_account_key: ${{secrets.GOOGLE_APPLICATION_CREDENTIALS}}
install_components: 'gke-gcloud-auth-plugin'
export_default_credentials: true

- name: 'Configure kubectl'
run: gcloud container clusters get-credentials hypermine-gke --region=asia-south1
- name: 'Configure kubectl'
run: gcloud container clusters get-credentials hypermine-gke-manual --region=asia-south1

- name: Replace tags
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__LATEST_RELEASE_TAG__#${{ env.LATEST_RELEASE_TAG }}#" {} \;
- name: Replace tags
run: find .deploy/deployment.yaml -type f -exec sed -i -e "s#__LATEST_RELEASE_TAG__#${{ env.LATEST_RELEASE_TAG }}#" {} \;

- name: 'Replace secrets'
run: find .deploy/deployment.yaml -type f -exec sed -i ''s/__GOOGLE_ARTIFACT_URL__/${{ secrets.GOOGLE_ARTIFACT_URL }}/g'' {} \;
- name: 'Replace secrets'
run: find .deploy/deployment.yaml -type f -exec sed -i ''s/__GOOGLE_ARTIFACT_REPO__/${{ secrets.GOOGLE_ARTIFACT_REPO }}/g'' {} \;
- name: 'Replace secrets'
run: find .deploy/deployment.yaml -type f -exec sed -i ''s/__GOOGLE_PROJECT_ID__/${{ secrets.GOOGLE_PROJECT_ID }}/g'' {} \;
- name: 'Deploy to GKE'
run: kubectl apply -f .deploy/deployment.yaml
- name: 'Replace secrets'
run: find .deploy/deployment.yaml -type f -exec sed -i ''s/__GOOGLE_ARTIFACT_URL__/${{ secrets.GOOGLE_ARTIFACT_URL }}/g'' {} \;
- name: 'Replace secrets'
run: find .deploy/deployment.yaml -type f -exec sed -i ''s/__GOOGLE_ARTIFACT_REPO__/${{ secrets.GOOGLE_ARTIFACT_REPO }}/g'' {} \;
- name: 'Replace secrets'
run: find .deploy/deployment.yaml -type f -exec sed -i ''s/__GOOGLE_PROJECT_ID__/${{ secrets.GOOGLE_PROJECT_ID }}/g'' {} \;
- name: 'Deploy to GKE'
run: kubectl apply -f .deploy/deployment.yaml

0 comments on commit bb825f5

Please sign in to comment.