Skip to content

Commit

Permalink
wip: cicd
Browse files Browse the repository at this point in the history
  • Loading branch information
Luscha committed Jan 14, 2025
1 parent 9167b36 commit 85cc647
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 10 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/odh-v2-core-writer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI/CD odh-v2-core-writer

on:
push:
paths:
- "infrastructure/raw-writer/**"
- "infrastructure/helm/raw-writer/**"
- ".github/workflows/odh-v2-core-writer.yaml"
workflow_dispatch:

env:
WORKING_DIRECTORY: infrastructure/raw-writer
KUBERNETES_NAMESPACE: core
KUBERNETES_VALUE_PATH: infrastructure/helm/raw-writer/values.yaml
KUBERNETES_CHART_PATH: infrastructure/helm/raw-writer/raw-writer
PROJECT_NAME: raw-writer

jobs:
build:
if: github.ref == 'refs/heads/refactor/noti-router' || github.ref == 'refs/heads/prod'
runs-on: ubuntu-22.04
concurrency: odh-v2-core-writer-build
steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Log in to GitHub Docker Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Manually build and push image
run: cd ${{ env.WORKING_DIRECTORY }} && ./build.sh

deploy:
if: github.ref == 'refs/heads/refactor/noti-router' || github.ref == 'refs/heads/prod'
needs:
- build
runs-on: ubuntu-22.04
concurrency: odh-v2-core-writer-build-deploy
environment: ${{ github.ref == 'refs/heads/refactor/noti-router' && 'test' || github.ref == 'refs/heads/prod' && 'prod' || 'unknown' }}
steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Deploy on cluster
uses: noi-techpark/github-actions/helm-deploy@v2
with:
k8s-name: ${{ env.PROJECT_NAME }}
k8s-namespace: ${{ env.KUBERNETES_NAMESPACE }}
chart-path: ${{ env.KUBERNETES_CHART_PATH }}
values-file: ${{ env.KUBERNETES_VALUE_PATH }}
aws-access-key-id: ${{ secrets[vars.AWS_KEY_ID] }}
aws-secret-access-key: ${{ secrets[vars.AWS_KEY_SECRET] }}
aws-eks-cluster-name: aws-main-eu-01
aws-region: eu-west-1
2 changes: 2 additions & 0 deletions infrastructure/helm/raw-writer/raw-writer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ env:
value: ingress
- name: APP_MQ_QUEUE
value: ingress
- name: APP_MQ_READY_EXCHANGE
value: ready
- name: APP_LOGLEVEL
value: INFO

Expand Down
2 changes: 2 additions & 0 deletions infrastructure/helm/raw-writer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ env:
value: ingress
- name: APP_MQ_QUEUE
value: ingress
- name: APP_MQ_READY_EXCHANGE
value: ready
- name: APP_MONGO_URI
valueFrom:
secretKeyRef:
Expand Down
6 changes: 3 additions & 3 deletions infrastructure/raw-writer/.env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
APP_MQ_URI=amqp://guest:guest@rabbitmq:5672
APP_MQ_EXCHANGE=ingress
APP_MQ_QUEUE=ingress
APP_MQ_READY_EXCHANGE=ready
APP_MQ_READY_QUEUE=ready
APP_MQ_ROUTED_EXCHANGE=routed
APP_MQ_ROUTED_QUEUE=routed
APP_MONGO_URI=mongodb://mongodb

APP_LOGLEVEL=DEBUG
17 changes: 10 additions & 7 deletions infrastructure/raw-writer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ import (
)

var cfg struct {
MQ_URI string
MQ_Exchange string
MQ_QUEUE string
LogLevel string `default:"INFO"`
MONGO_URI string
DB_PREFIX string
MQ_URI string
MQ_Exchange string
MQ_QUEUE string
MQ_READY_EXCHANGE string
LogLevel string `default:"INFO"`
MONGO_URI string
DB_PREFIX string
}

type mqErr struct {
Expand Down Expand Up @@ -96,6 +97,8 @@ func setupMQ() <-chan *message.Message {
}

func setupReadyPublisher() *amqp.Publisher {
// setup only open a connection with rabbitmq and tells publisher that
// exchange needs to be "direct". Exchange creation is delegated to message publish
amqpConfig := amqp.NewDurablePubSubConfig(cfg.MQ_URI, amqp.GenerateQueueNameConstant(""))
amqpConfig.Exchange.Durable = true
amqpConfig.Exchange.AutoDeleted = false
Expand Down Expand Up @@ -173,7 +176,7 @@ func handleMqMsg(msg *message.Message) *mqErr {
return nil, err
}
msg := message.NewMessage(watermill.NewUUID(), messagePayload)
return nil, readyPublisher.Publish("ready", msg)
return nil, readyPublisher.Publish(cfg.MQ_READY_EXCHANGE, msg)
}, nil),
)

Expand Down

0 comments on commit 85cc647

Please sign in to comment.