Skip to content

Commit

Permalink
Add gamma environment infrastructure :3
Browse files Browse the repository at this point in the history
  • Loading branch information
WillNilges committed Jan 27, 2025
1 parent 8221f36 commit 9499852
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 30 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/build-push-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and Publish Docker Image
permissions: read-all

on:
workflow_call:
inputs:
environment:
required: true
type: string
image_tag:
required: true
type: string

jobs:
push_to_registry_env:
name: Push Docker Image to Docker Hub
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: willnilges/meshdb

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ inputs.image_tag }}
labels: ${{ steps.meta.outputs.labels }}
7 changes: 6 additions & 1 deletion .github/workflows/helm-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
environment:
required: true
type: string
imageTag:
required: true
type: string

jobs:
helm_deploy:
Expand Down Expand Up @@ -47,7 +50,9 @@ jobs:
--create-namespace \
-f ./infra/admin-map/values.yaml \
--set adminmap.fqdn.legacy="${{ vars.ADMIN_FQDN_LEGACY }}" \
--set adminmap.fqdn="${{ vars.ADMIN_FQDN }}"
--set adminmap.fqdn="${{ vars.ADMIN_FQDN }}" \
--set adminmap.meshDbUrl="${{ vars.REACT_APP_MESHDB_URL }}" \
--set adminmap.image.tag="${{ inputs.imageTag }}"
# Rolling restart
kubectl --kubeconfig ./config --server https://${{ secrets.SSH_TARGET_IP }}:6443 -n ${{ vars.APP_NAMESPACE }} rollout restart deploy
28 changes: 28 additions & 0 deletions .github/workflows/publish-and-deploy-gamma.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish and Deploy (Gamma)

on:
push:
branches:
#- meshdb
- meshdb-admin-dev

jobs:
# Dev and Prod use the same image
push_to_registry_prod:
name: Push to dev
uses: ./.github/workflows/build-push-image.yaml
with:
environment: gamma1
image_tag: willnilges/network-map:admin-helm-gamma
secrets: inherit
if: github.ref == 'refs/heads/meshdb-admin-dev'

deploy_to_dev3:
name: Deploy to gamma1
uses: ./.github/workflows/helm-deploy.yaml
with:
environment: gamma1
imageTag: admin-helm-gamma
secrets: inherit
if: github.ref == 'refs/heads/meshdb-admin-dev'
needs: push_to_registry
42 changes: 13 additions & 29 deletions .github/workflows/publish-and-deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Docker Image
name: Publish and Deploy

on:
push:
Expand All @@ -7,50 +7,33 @@ on:
- meshdb-admin

jobs:
push_to_registry:
name: Push Docker Image to Docker Hub
runs-on: ubuntu-latest
# Dev and Prod use the same image
push_to_registry_prod:
name: Push to prod
uses: ./.github/workflows/build-push-image.yaml
with:
environment: prod1
image_tag: willnilges/network-map:admin-helm
secrets: inherit
if: github.ref == 'refs/heads/meshdb-admin'
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: willnilges/network-map

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: "willnilges/network-map:admin-helm"
labels: ${{ steps.meta.outputs.labels }}

deploy_to_dev3:
name: Deploy to dev 3
uses: ./.github/workflows/helm-deploy.yaml
with:
environment: dev3
imageTag: admin-helm
secrets: inherit
if: github.ref == 'refs/heads/meshdb-admin'
needs: push_to_registry
needs: push_to_registry_prod

deploy_to_prod1:
name: Deploy to prod 1
uses: ./.github/workflows/helm-deploy.yaml
needs: deploy_to_dev3
with:
environment: prod1
imageTag: admin-helm
secrets: inherit
if: github.ref == 'refs/heads/meshdb-admin'

Expand All @@ -60,5 +43,6 @@ jobs:
needs: deploy_to_prod1
with:
environment: prod2
imageTag: admin-helm
secrets: inherit
if: github.ref == 'refs/heads/meshdb-admin'
2 changes: 2 additions & 0 deletions infra/admin-map/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ spec:
env:
- name: NODE_ENV
value: production
- name: REACT_APP_MESHDB_URL
value: {{.Values.adminmap.meshDbUrl}}
ports:
- name: http
containerPort: {{ .Values.adminmap.port }}
Expand Down

0 comments on commit 9499852

Please sign in to comment.