Merge branch 'main' into prod #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD dc-echarging-ocpi-neogy | |
on: | |
push: | |
paths: | |
- "collectors/echarging-ocpi/**" | |
- ".github/workflows/dc-echarging-ocpi-neogy.yml" | |
env: | |
WORKING_DIRECTORY: collectors/echarging-ocpi | |
DOCKER_IMAGE: ghcr.io/noi-techpark/opendatahub-collectors/dc-echarging-ocpi | |
DOCKER_TAG: ${{ github.sha }} | |
KUBERNETES_NAMESPACE: collector | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
concurrency: dc-echarging-ocpi-neogy-build | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Build and push images | |
uses: noi-techpark/github-actions/docker-build-and-push@v2 | |
with: | |
working-directory: ${{ env.WORKING_DIRECTORY }}/infrastructure | |
docker-username: ${{ github.actor }} | |
docker-password: ${{ secrets.GITHUB_TOKEN }} | |
deploy-test: | |
if: github.ref == 'refs/heads/main' | |
needs: | |
- build | |
runs-on: ubuntu-22.04 | |
concurrency: dc-echarging-ocpi-neogy-deploy-test | |
environment: test | |
env: | |
VALUES_YAML: collectors/echarging-ocpi/infrastructure/helm/neogy.yaml | |
K8S_NAME: dc-echarging-ocpi-neogy | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Write environment-specific Helm values | |
run: | | |
cat <<EOF > override.yml | |
image: | |
repository: ${{ env.DOCKER_IMAGE }} | |
tag: ${{ env.DOCKER_TAG }} | |
pullPolicy: "IfNotPresent" | |
env: | |
LOG_LEVEL: "INFO" | |
envSecret: | |
OCPI_TOKENS: ${{ secrets.ECHARGING_OCPI_NEOGY_TOKENS }} | |
PULL_LOCATIONS_ENDPOINT: ${{ secrets.ECHARGING_NEOGY_OCPI_URL}}?limit=200 | |
PULL_TOKEN: "${{ secrets.ECHARGING_NEOGY_OCPI_TOKEN_C }}" | |
EOF | |
# Merge yaml files https://mikefarah.gitbook.io/yq/operators/multiply-merge | |
yq -i '. *= load("override.yml")' ${{env.VALUES_YAML}} | |
- name: Deploy on cluster | |
uses: noi-techpark/github-actions/helm-deploy@v2 | |
with: | |
k8s-name: ${{ env.K8S_NAME }} | |
k8s-namespace: collector | |
chart-path: helm/generic-collector | |
values-file: ${{ env.VALUES_YAML }} | |
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 | |
deploy-prod: | |
if: github.ref == 'refs/heads/prod' | |
needs: | |
- build | |
runs-on: ubuntu-22.04 | |
concurrency: dc-echarging-ocpi-neogy-deploy-prod | |
environment: prod | |
env: | |
VALUES_YAML: collectors/echarging-ocpi/infrastructure/helm/neogy.yaml | |
K8S_NAME: dc-echarging-ocpi-neogy | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Write environment-specific Helm values | |
run: | | |
cat <<EOF > override.yml | |
image: | |
repository: ${{ env.DOCKER_IMAGE }} | |
tag: ${{ env.DOCKER_TAG }} | |
pullPolicy: "IfNotPresent" | |
env: | |
LOG_LEVEL: "INFO" | |
envSecret: | |
OCPI_TOKENS: ${{ secrets.ECHARGING_OCPI_NEOGY_TOKENS }} | |
PULL_LOCATIONS_ENDPOINT: ${{ secrets.ECHARGING_NEOGY_OCPI_URL}}?limit=200 | |
PULL_TOKEN: "${{ secrets.ECHARGING_NEOGY_OCPI_TOKEN_C }}" | |
EOF | |
# Merge yaml files https://mikefarah.gitbook.io/yq/operators/multiply-merge | |
yq -i '. *= load("override.yml")' ${{env.VALUES_YAML}} | |
cat <<EOF > override.yml | |
ingress: | |
enabled: true | |
annotations: | |
cert-manager.io/issuer: "letsencrypt-prod" | |
className: nginx | |
tls: | |
- hosts: | |
- neogy.ocpi.io.opendatahub.com | |
secretName: tls-ocpi-neogy | |
hosts: | |
- host: neogy.ocpi.io.opendatahub.com | |
paths: | |
- path: "/" | |
pathType: Prefix | |
EOF | |
# Different from above, we only do a shallow merge, so that original hosts are replaced, not appended | |
yq -i '. += load("override.yml")' ${{env.VALUES_YAML}} | |
- name: Deploy on cluster | |
uses: noi-techpark/github-actions/helm-deploy@v2 | |
with: | |
k8s-name: ${{ env.K8S_NAME }} | |
k8s-namespace: collector | |
chart-path: helm/generic-collector | |
values-file: ${{ env.VALUES_YAML }} | |
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 |