Skip to content

Commit 9304638

Browse files
committed
refactor deployments
1 parent b400b59 commit 9304638

File tree

6 files changed

+37
-24
lines changed

6 files changed

+37
-24
lines changed

.github/workflows/backend.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
push:
55
branches: ["main"]
66
tags:
7-
- "backend@STAGING-v*"
8-
- "backend@v*"
7+
- "STAGING-v*"
8+
- "v*"
99

1010
env:
1111
AWS_REGION: ap-southeast-1
@@ -33,6 +33,17 @@ jobs:
3333
id: login-ecr
3434
uses: aws-actions/amazon-ecr-login@v1
3535

36+
- name: Determine environment and image
37+
id: determine-env
38+
run: |
39+
if [[ ${{ github.ref }} == refs/tags/STAGING-v* ]]; then
40+
echo "ENVIRONMENT=staging" >> $GITHUB_OUTPUT
41+
echo "IMAGE=${{ env.IMAGE }}" >> $GITHUB_OUTPUT
42+
else
43+
echo "ENVIRONMENT=development" >> $GITHUB_OUTPUT
44+
echo "IMAGE=${{ env.IMAGE }}" >> $GITHUB_OUTPUT
45+
fi
46+
3647
- name: Extract metadata (tags, labels) for Docker
3748
id: meta
3849
uses: docker/metadata-action@v5
@@ -42,17 +53,6 @@ jobs:
4253
tags: |
4354
type=sha
4455
45-
- name: Determine environment
46-
id: determine-env
47-
run: |
48-
if [[ ${{ github.ref }} == refs/tags/backend@STAGING-v* ]]; then
49-
echo "ENVIRONMENT=staging" >> $GITHUB_OUTPUT
50-
elif [[ ${{ github.ref }} == refs/tags/backend@v* ]]; then
51-
echo "ENVIRONMENT=production" >> $GITHUB_OUTPUT
52-
else
53-
echo "ENVIRONMENT=development" >> $GITHUB_OUTPUT
54-
fi
55-
5656
- name: Build and push Docker images
5757
uses: docker/build-push-action@v5
5858
with:

.kube/backend/base/service.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,3 @@ spec:
1010
- protocol: TCP
1111
port: 8000
1212
targetPort: 8000
13-
---
14-
apiVersion: elbv2.k8s.aws/v1beta1
15-
kind: TargetGroupBinding
16-
metadata:
17-
name: hansards-back
18-
spec:
19-
serviceRef:
20-
name: hansards-back
21-
port: 8000
22-
targetGroupARN: arn:aws:elasticloadbalancing:ap-southeast-1:767397910274:targetgroup/hansards-back/405d7e014da59c37
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
apiVersion: elbv2.k8s.aws/v1beta1
3+
kind: TargetGroupBinding
4+
metadata:
5+
name: hansards-back
6+
spec:
7+
serviceRef:
8+
name: hansards-back
9+
port: 8000
10+
targetGroupARN: arn:aws:elasticloadbalancing:ap-southeast-1:767397910274:targetgroup/hansards-back/405d7e014da59c37

.kube/backend/overlays/production/kustomization.yml renamed to .kube/backend/overlays/dev/kustomization.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
33
resources:
44
- ../../base
5+
- ingress.yaml
56
images:
67
- name: IMAGE_NAME_PLACEHOLDER
78
# Use the correct image from AWS ECR!
89
newName: 767397910274.dkr.ecr.ap-southeast-1.amazonaws.com/hansards-back
10+
namespace: hansards
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
apiVersion: elbv2.k8s.aws/v1beta1
3+
kind: TargetGroupBinding
4+
metadata:
5+
name: hansards-back
6+
spec:
7+
serviceRef:
8+
name: hansards-back
9+
port: 8000
10+
targetGroupARN: arn:aws:elasticloadbalancing:ap-southeast-1:767397910274:targetgroup/hansards-back-staging/7db92f970181dcea

.kube/backend/overlays/staging/kustomization.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
33
resources:
44
- ../../base
5-
5+
- ingress.yaml
66
images:
77
- name: IMAGE_NAME_PLACEHOLDER
88
# Use the correct image from AWS ECR!
99
newName: 767397910274.dkr.ecr.ap-southeast-1.amazonaws.com/hansards-back
10+
namespace: hansards-staging # deploy to dev cluster but different namespace

0 commit comments

Comments
 (0)