1
+ name : Build and Deploy Website To Stage
2
+ permissions :
3
+ contents : read
4
+
5
+ on :
6
+ push :
7
+ branches :
8
+ - development
9
+
10
+ env :
11
+ APP_NAME : gofr-website
12
+ WEBSITE_REGISTRY : ghcr.io
13
+ GAR_PROJECT : raramuri-tech
14
+ GAR_REGISTRY : kops-dev
15
+ CLUSTER_NAME : raramuri-tech
16
+ CLUSTER_PROJECT : raramuri-tech
17
+ NAMESPACE : gofr-dev
18
+ NAMESPACE_STAGE : gofr-dev-stg
19
+
20
+ jobs :
21
+ dockerize :
22
+ permissions :
23
+ contents : read
24
+ packages : write
25
+ runs-on : ubuntu-latest
26
+ outputs :
27
+ image : ${{ steps.output-image.outputs.image }}
28
+ name : 🐳 Dockerize
29
+ steps :
30
+ - name : Checkout Code
31
+ uses : actions/checkout@v5
32
+
33
+ - name : Set up Docker Buildx
34
+ uses : docker/setup-buildx-action@v3
35
+
36
+ - name : Login to GAR
37
+ uses : docker/login-action@v3
38
+ with :
39
+ registry : us-central1-docker.pkg.dev
40
+ username : _json_key
41
+ password : ${{ secrets.GOFR_WEBSITE_GOFR_DEV_STG_DEPLOYMENT_KEY }}
42
+
43
+ - name : Log in to the GitHub Container registry
44
+ uses : docker/login-action@v3
45
+ with :
46
+ registry : ${{ env.WEBSITE_REGISTRY }}
47
+ username : ${{ github.actor }}
48
+ password : ${{ secrets.GITHUB_TOKEN }}
49
+
50
+ - name : Download UI Image
51
+ run : |
52
+ docker pull ${{ env.WEBSITE_REGISTRY }}/gofr-dev/website:latest
53
+
54
+ - name : Determine Image Tag
55
+ id : determine-tag
56
+ run : |
57
+ if [[ "${{ github.ref }}" == refs/tags/* ]]; then
58
+ TAG=${GITHUB_REF#refs/tags/}
59
+ else
60
+ TAG=${{ github.sha }}
61
+ fi
62
+ echo "TAG=$TAG" >> $GITHUB_ENV
63
+
64
+
65
+ - name : Build and Push Image
66
+ uses : docker/build-push-action@v6
67
+ with :
68
+ push : true
69
+ context : ./
70
+ file : ./docs/Dockerfile
71
+ tags : us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY }}/${{ env.APP_NAME }}:${{ env.TAG }}
72
+
73
+ - id : output-image
74
+ run : echo "image=`echo us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY }}/${{ env.APP_NAME }}:${{ env.TAG }}`" >> "$GITHUB_OUTPUT"
75
+
76
+ deployment_stage :
77
+ runs-on : ubuntu-latest
78
+ name : 🚀 Deploy-Stage
79
+ needs : dockerize
80
+ container :
81
+ image : ghcr.io/zopsmart/gha-images:deployments-0.1.3
82
+ options : --rm
83
+ env :
84
+ image : ${{needs.dockerize.outputs.image}}
85
+
86
+ steps :
87
+ - name : Checkout Code
88
+ uses : actions/checkout@v5
89
+
90
+ - name : Authorize to GCP service account
91
+ uses : google-github-actions/auth@v2
92
+ with :
93
+ credentials_json : ${{ secrets.GOFR_WEBSITE_GOFR_DEV_STG_DEPLOYMENT_KEY }}
94
+
95
+ - name : Set GCloud Project and Fetch Cluster Credentials
96
+ run : gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --region=us-central1 --project=${{ env.CLUSTER_PROJECT }}
97
+
98
+ - name : Update Deployment Image
99
+ run : kubectl set image deployment/${{ env.APP_NAME }} ${{ env.APP_NAME }}=${{ env.image }} --namespace ${{ env.NAMESPACE_STAGE }}
0 commit comments