Skip to content

Commit f6c07e1

Browse files
authored
Cric 2223 move circleci to GitHub actions (#1963)
* Updated config.yml * Updated config.yml * Github actions deploy workflow
1 parent 1006e06 commit f6c07e1

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed

.github/workflows/deploy-dev.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Deploy Dev
2+
3+
on:
4+
push:
5+
tags:
6+
- 'dev_*'
7+
8+
jobs:
9+
deploy:
10+
uses: ./.github/workflows/deploy.yml
11+
with:
12+
project_id: orsp-dev
13+
cluster: orsp-pub-dev
14+
cluster_region: us-central1
15+
artifact_registry: orsp-repo
16+
registry_region: us-central1
17+
deployment: orsp-pub-dev
18+
image: orsp-dev-img
19+
project_number: 18883205905
20+
service_account: github-dev-deploy@orsp-dev.iam.gserviceaccount.com

.github/workflows/deploy.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Build and deploy to GKE
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
project_id:
7+
description: 'Google Cloud Project ID'
8+
required: true
9+
type: string
10+
cluster:
11+
description: 'GKE Cluster Name'
12+
required: true
13+
type: string
14+
cluster_region:
15+
description: 'GKE Cluster Region'
16+
required: true
17+
type: string
18+
artifact_registry:
19+
description: 'Artifact Registry Name'
20+
required: true
21+
type: string
22+
registry_region:
23+
description: 'Artifact Registry Region'
24+
required: true
25+
type: string
26+
deployment:
27+
description: 'Kubernetes Deployment Name'
28+
required: true
29+
type: string
30+
image:
31+
description: 'Docker Image Name'
32+
required: true
33+
type: string
34+
project_number:
35+
description: 'Google Cloud Project Number'
36+
required: true
37+
type: string
38+
service_account:
39+
description: 'Google Cloud Service Account Email'
40+
required: true
41+
type: string
42+
43+
concurrency:
44+
group: deploy-${{ github.repository }}-${{ github.ref }}
45+
cancel-in-progress: true
46+
47+
permissions:
48+
contents: read
49+
id-token: write
50+
51+
jobs:
52+
deploy:
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: Checkout Repository
56+
uses: actions/checkout@v4
57+
58+
- name: Authenticate to Google Cloud
59+
id: auth
60+
uses: google-github-actions/auth@v2
61+
with:
62+
workload_identity_provider: projects/${{ inputs.project_number }}/locations/global/workloadIdentityPools/orsp-dev-workloadpool/providers/github
63+
service_account: ${{ inputs.service_account }}
64+
65+
- name: Setup Gcloud
66+
uses: google-github-actions/setup-gcloud@v2
67+
68+
- name: Docker Login
69+
uses: docker/login-action@v3
70+
with:
71+
registry: ${{ inputs.registry_region }}-docker.pkg.dev
72+
username: oauth2accesstoken
73+
password: ${{ steps.auth.outputs.auth_token }}
74+
75+
- name: Extract Tag
76+
run: |
77+
TAG=${GITHUB_REF#refs/tags/}
78+
echo "IMAGE_URI=${{ inputs.registry_region }}-docker.pkg.dev/${{ inputs.project_id }}/${{ inputs.artifact_registry }}/${{ inputs.image }}:$TAG" >> $GITHUB_ENV
79+
80+
- name: Build and Push Docker Image
81+
uses: docker/build-push-action@v5
82+
with:
83+
context: .
84+
push: true
85+
tags: ${{ env.IMAGE_URI }}
86+
cache-from: type=gha
87+
cache-to: type=gha,mode=max
88+
89+
- name: Get GKE Credentials
90+
uses: google-github-actions/get-gke-credentials@v2
91+
with:
92+
cluster_name: ${{ inputs.cluster }}
93+
location: ${{ inputs.cluster_region }}
94+
95+
- name: Deploy to Kubernetes
96+
run: |
97+
set -e
98+
kubectl set image deployment/${{ inputs.deployment }} orsp-pub=$IMAGE_URI
99+
kubectl rollout status deployment/${{ inputs.deployment }} --timeout=10m
100+
kubectl get pods
101+
kubectl describe deployment ${{ inputs.deployment }}

0 commit comments

Comments
 (0)