generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (58 loc) · 2.1 KB
/
build-deploy-poc.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
name: Build and Deploy (POC)
on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
KUBE_CLUSTER: ${{ secrets.DEV_KUBE_CLUSTER }}
KUBE_NAMESPACE: ${{ secrets.DEV_KUBE_NAMESPACE }}
KUBE_CERT: ${{ secrets.DEV_KUBE_CERT }}
KUBE_TOKEN: ${{ secrets.DEV_KUBE_TOKEN }}
ECR_REGISTRY: ${{ vars.ECR_REGISTRY }}
ECR_REPOSITORY: ${{ vars.DEVELOPMENT_ECR_REPOSITORY }}
IMAGE_TAG: ${{ vars.ECR_REGISTRY }}/${{ vars.DEVELOPMENT_ECR_REPOSITORY }}:${{ github.sha }}
jobs:
build-push:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.DEVELOPMENT_ECR_ROLE_TO_ASSUME }}
aws-region: eu-west-2
- uses: aws-actions/amazon-ecr-login@v2
- run: |
docker build -t ${IMAGE_TAG} .
docker push ${IMAGE_TAG}
deploy-to-dev:
needs: build-push
runs-on: ubuntu-latest
container: alpine/k8s:1.23.17
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Authenticate to the cluster
run: |
echo "${KUBE_CERT}" > ca.crt
kubectl config set-cluster ${KUBE_CLUSTER} --certificate-authority=./ca.crt --server=https://${KUBE_CLUSTER}
kubectl config set-credentials deploy-user --token=${KUBE_TOKEN}
kubectl config set-context ${KUBE_CLUSTER} --cluster=${KUBE_CLUSTER} --user=deploy-user --namespace=${KUBE_NAMESPACE}
kubectl config get-contexts
kubectl config use-context ${KUBE_CLUSTER}
- name: Helm install
run: |
helm upgrade operations-engineering-metadata-poc \
helm/operations-engineering-metadata-poc \
--install \
--force \
--wait \
--timeout 10m \
--namespace ${KUBE_NAMESPACE} \
--set image.tag=${{ github.sha }} \
-f helm/operations-engineering-metadata-poc/values.yaml \
-f helm/operations-engineering-metadata-poc/values-poc.yaml