-
Notifications
You must be signed in to change notification settings - Fork 268
113 lines (96 loc) · 3.23 KB
/
website_prod.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Build and Deploy
on:
push:
tags:
- "v*.*.*"
branches:
- main
- development
env:
APP_NAME: gofr-website
WEBSITE_REGISTRY: ghcr.io
GAR_PROJECT: raramuri-tech
GAR_REGISTRY: kops-dev
CLUSTER_NAME: raramuri-tech
CLUSTER_PROJECT: raramuri-tech
NAMESPACE: gofr-dev
jobs:
build:
runs-on: ubuntu-latest
name: 🔧Build
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the GitHub Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.WEBSITE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download UI Image
run: |
docker pull ${{ env.WEBSITE_REGISTRY }}/gofr-dev/website:latest
- name: Build Image
uses: docker/build-push-action@v4
with:
push: false
context: ./
file: ./docs/Dockerfile
dockerize:
if: ${{ startsWith(github.ref, 'refs/tags/v')}}
runs-on: ubuntu-latest
outputs:
image: ${{ steps.output-image.outputs.image }}
name: 🐳 Dockerize
needs: build
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GAR
uses: docker/login-action@v3
with:
registry: us-central1-docker.pkg.dev
username: _json_key
password: ${{ secrets.deploy_key }}
- name: Log in to the GitHub Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.WEBSITE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download UI Image
run: |
docker pull ${{ env.WEBSITE_REGISTRY }}/gofr-dev/website:latest
- name: Build and Push Image Stage
uses: docker/build-push-action@v4
with:
push: true
context: ./
file: ./docs/Dockerfile
tags: us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY }}/${{ env.APP_NAME }}:${{ github.sha }}
- id: output-image
run: echo "image=`echo us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY }}/${{ env.APP_NAME }}:${{ github.sha }}`" >> "$GITHUB_OUTPUT"
deployment:
runs-on: ubuntu-latest
name: 🚀 Deploy
needs: dockerize
container:
image: ghcr.io/zopsmart/gha-images:deployments-0.1.3
options: --rm
env:
image: ${{needs.dockerize.outputs.image}}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Authorize to GCP service account
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.deploy_key }}
- name: Set GCloud Project and Fetch Cluster Credentials
run: gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --region=us-central1 --project=${{ env.CLUSTER_PROJECT }}
- name: Update Deployment Image
run: kubectl set image deployment/${{ env.APP_NAME }} ${{ env.APP_NAME }}=${{ env.image }} --namespace ${{ env.NAMESPACE }}