Skip to content

Commit 4f85e95

Browse files
feat: add v3 iac
1 parent 66bc3d1 commit 4f85e95

File tree

2 files changed

+69
-7
lines changed

2 files changed

+69
-7
lines changed

.github/workflows/deploy-v3.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build and Deploy
2+
3+
on:
4+
push:
5+
tags:
6+
- "v3.*.*"
7+
8+
env:
9+
DEPLOYMENT: "web-v3"
10+
CLUSTER: "pickup-cluster"
11+
12+
jobs:
13+
push_to_registry:
14+
name: Push Docker image to Docker Hub
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Check out the repo
18+
uses: actions/checkout@v3
19+
with:
20+
ref: v3
21+
22+
- name: Log in to Docker Hub
23+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
24+
with:
25+
username: ${{ secrets.DOCKER_USERNAME }}
26+
password: ${{ secrets.DOCKER_TOKEN }}
27+
28+
- name: Extract metadata (tags, labels) for Docker
29+
id: meta
30+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
31+
with:
32+
images: joinpickup/web-v3
33+
tags: latest, ${{ github.ref_name }}
34+
35+
- name: Build and push Docker image
36+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
37+
with:
38+
context: ./code
39+
push: true
40+
tags: ${{ steps.meta.outputs.tags }}
41+
labels: ${{ steps.meta.outputs.labels }}
42+
deploy:
43+
needs: push_to_registry
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Check out the repo
47+
uses: actions/checkout@v3
48+
with:
49+
ref: v3
50+
51+
- name: Install Doctl
52+
uses: digitalocean/action-doctl@v2
53+
with:
54+
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
55+
56+
- name: Save DigitalOcean kubeconfig with short-lived credentials
57+
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 $(echo $CLUSTER)
58+
59+
- name: Deploy to DigitalOcean Kubernetes
60+
run: sed -e 's|$TAG|${{ github.ref_name }}|g' -e 's|$VERSION|${{ github.ref_name }}|g' $GITHUB_WORKSPACE/iac/deployment-v3.yaml | kubectl apply -f -
61+
62+
- name: Verify deployment
63+
run: kubectl -n prod rollout status deployment/$(echo $DEPLOYMENT)

.github/workflows/deploy.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Build and Deploy
22

3-
on:
3+
on:
44
push:
55
tags:
6-
- 'v*.*.*'
6+
- "v2.*.*"
77

88
env:
99
DEPLOYMENT: "web"
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- name: Check out the repo
1818
uses: actions/checkout@v3
19-
19+
2020
- name: Log in to Docker Hub
2121
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
2222
with:
@@ -28,7 +28,7 @@ jobs:
2828
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
2929
with:
3030
images: joinpickup/web
31-
tags: latest, ${{ github.ref_name }}
31+
tags: latest, ${{ github.ref_name }}
3232

3333
- name: Build and push Docker image
3434
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
@@ -40,9 +40,9 @@ jobs:
4040
deploy:
4141
needs: push_to_registry
4242
runs-on: ubuntu-latest
43-
steps:
43+
steps:
4444
- name: Checkout Master
45-
uses: actions/checkout@main
45+
uses: actions/checkout@main
4646
- name: Install Doctl
4747
uses: digitalocean/action-doctl@v2
4848
with:
@@ -56,4 +56,3 @@ jobs:
5656

5757
- name: Verify deployment
5858
run: kubectl -n prod rollout status deployment/$(echo $DEPLOYMENT)
59-

0 commit comments

Comments
 (0)