1+ name : Build and Deploy (prod)
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+
7+ env :
8+ SERVICE_NAME : orphan-domain-handler
9+ NAMESPACE : kops-dev
10+ CLUSTER_NAME : raramuri-tech
11+ CLUSTER_PROJECT : raramuri-tech
12+ GAR_PROJECT : raramuri-tech
13+ GAR_REGISTRY : kops-dev
14+
15+ jobs :
16+ dockerize :
17+ runs-on : ubuntu-latest
18+ name : 🐳 Dockerize
19+
20+ outputs :
21+ image : ${{ steps.output-image.outputs.image }}
22+ steps :
23+ - uses : actions/checkout@v4
24+ - uses : actions/setup-go@v4
25+ with :
26+ go-version : ' 1.25.1'
27+ - name : Get dependencies
28+ run : |
29+ go mod download
30+
31+ - name : Build
32+ run : |
33+ cd ./orphan-domain-handler
34+ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -buildvcs=false -o main
35+
36+ - name : Login to GAR
37+ uses : docker/login-action@v2
38+ with :
39+ registry : us-central1-docker.pkg.dev
40+ username : _json_key
41+ password : ${{ secrets.ORPHAN_DOMAIN_HANDLER_KOPS_DEV_STG_DEPLOYMENT_KEY }}
42+
43+ - name : Build and Push Docker Image to GAR
44+ uses : docker/build-push-action@v2
45+ with :
46+ push : true
47+ context : ./orphan-domain-handler
48+ file : ./DockerfileODH
49+ tags :
50+ us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY }}/${{ env.NAMESPACE }}/${{ env.SERVICE_NAME }}:${{ github.sha }}
51+ - id : output-image
52+ run :
53+ echo "image=`echo us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY }}/${{ env.NAMESPACE }}/${{ env.SERVICE_NAME }}:${{ github.sha }}`" >> "$GITHUB_OUTPUT"
54+
55+ deployment :
56+ runs-on : ubuntu-latest
57+ needs : dockerize
58+ name : 🚀 Deploy
59+ env :
60+ image : ${{ needs.dockerize.outputs.image }}
61+
62+ steps :
63+ - name : Checkout Code
64+ uses : actions/checkout@v2
65+
66+ - name : Authorize to GCP service account
67+ uses : google-github-actions/auth@v2
68+ with :
69+ credentials_json : ${{ secrets.ORPHAN_DOMAIN_HANDLER_KOPS_DEV_DEPLOYMENT_KEY }}
70+
71+ - name : Set up Cloud SDK
72+ uses : google-github-actions/setup-gcloud@v2
73+
74+ - name : Update Kubectl component
75+ run : gcloud --quiet components update kubectl
76+
77+ - name : Set GCloud Project and Fetch Cluster Credentials
78+ run :
79+ gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --region=us-central1 --project=${{ env.CLUSTER_PROJECT }}
80+
81+ - name : Update Deployment Image
82+ run :
83+ kubectl set image deployment/${{ env.SERVICE_NAME }} ${{ env.SERVICE_NAME }}=${{ env.image }} --namespace ${{ env.NAMESPACE }}
0 commit comments