forked from Sunbird-Obsrv/obsrv-core
-
Notifications
You must be signed in to change notification settings - Fork 7
161 lines (145 loc) · 5.49 KB
/
build_and_deploy.yaml
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Obsrv Core service build and deploy workflow
run-name: Workflow run for ${{ github.ref }}
on:
push:
tags:
- '*'
jobs:
check-tag:
runs-on: ubuntu-latest
outputs:
ALLOWED_TAG: ${{ steps.tag-checker.outputs.TRIGGER_ALLOWED }}
steps:
- name: Check if tag is one in list of current releases
id: tag-checker
run: |
(echo -n TRIGGER_ALLOWED= && echo 'print("${{ github.ref_name }}".split("_")[0]
in ${{ vars.CURRENT_RELEASE }})' | python3) >> "$GITHUB_OUTPUT"
docker-build:
needs: check-tag
if: needs.check-tag.outputs.ALLOWED_TAG == 'True'
runs-on: ubuntu-latest
strategy:
matrix:
include:
- image: "extractor"
target: "extractor-image"
- image: "preprocessor"
target: "preprocessor-image"
- image: "denormalizer"
target: "denormalizer-image"
- image: "transformer"
target: "transformer-image"
- image: "druid-router"
target: "router-image"
- image: "merged-pipeline"
target: "merged-image"
- image: "master-data-processor"
target: "master-data-processor-image"
- image: "kafka-connector"
target: "kafka-connector-image"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Maven Build
run: |
mvn clean install
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to docker hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build merged-pipeline image and push
uses: docker/build-push-action@v4
with:
platforms: linux/amd64
target: merged-image
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/merged-pipeline:${{ github.ref_name }}
- name: Build merged-pipeline image and push
uses: docker/build-push-action@v4
with:
platforms: linux/amd64
target: master-data-processor-image
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/master-data-processor:${{ github.ref_name }}
- name: Build merged-pipeline image and push
uses: docker/build-push-action@v4
with:
platforms: linux/amd64
target: kafka-connector-image
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/kafka-connector:${{ github.ref_name }}
- name: Build ${{matrix.image}} image and push
uses: docker/build-push-action@v4
with:
platforms: linux/amd64
target: ${{matrix.target}}
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{matrix.image}}:${{ github.ref_name }}
aws-deploy:
needs: [check-tag, docker-build]
if: needs.check-tag.outputs.ALLOWED_TAG == 'True'
runs-on: ubuntu-latest
environment: aws-dev
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Terragrunt
uses: autero1/action-terragrunt@v1.1.0
with:
terragrunt_version: v0.45.8
- name: Terragrunt installation
run: terragrunt --version
- name: Clone the terraform deployment repo
uses: actions/checkout@v3
with:
repository: ${{ vars.DEPLOY_REPO }}
path: deploy
ref: ${{ vars.DEPLOY_REPO_REF }}
- name: Fetch and update kubeconfig file
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ vars.AWS_REGION }}
run: |
aws eks --region ${{ vars.AWS_REGION }} update-kubeconfig --name ${{ vars.KUBERNETES_CLUSTER_NAME }}
- name: Run terraform init and apply
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ vars.AWS_REGION }}
AWS_TERRAFORM_BACKEND_BUCKET_NAME: ${{ vars.AWS_TERRAFORM_BACKEND_BUCKET_NAME }}
AWS_TERRAFORM_BACKEND_BUCKET_REGION: ${{ vars.AWS_TERRAFORM_BACKEND_BUCKET_REGION }}
KUBE_CONFIG_PATH: ~/.kube/config
run: |
cd deploy/terraform/aws
terragrunt init
terragrunt apply -auto-approve -var merged_pipeline_enabled={{ vars.MERGED_PIPELINE || 'true' }} --replace='module.flink.helm_release.flink' \
-var flink_image_tag=${{ github.ref_name }}
azure-deploy:
needs: [check-tag, docker-build]
if: needs.check-tag.outputs.ALLOWED_TAG == 'True' && vars.CLOUD_PROVIDER == 'azure'
runs-on: ubuntu-latest
steps:
- name: Clone the terraform deployment repo
uses: actions/checkout@v3
with:
repository: ${{ vars.DEPLOY_REPO }}
path: deploy
ref: ${{ vars.DEPLOY_REPO_REF }}
- name: Run terraform init and apply
env:
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
run: |
cd deploy/terraform/azure
terragrunt init
terragrunt apply -auto-approve -replace=module.flink.helm_release.flink \
-var flink_container_registry=${{ secrets.DOCKERHUB_USERNAME }} \
-var flink_image_tag=${{ github.ref_name }}