Skip to content

Merge remote-tracking branch 'origin/develop' into develop #365

Merge remote-tracking branch 'origin/develop' into develop

Merge remote-tracking branch 'origin/develop' into develop #365

name: Deploy images to k8s
permissions:
id-token: write
contents: read
on:
push:
branches:
- 'main'
- 'staging'
paths:
- 'app/**'
- 'api/**'
- 'webshot/**'
- '.github/**'
workflow_dispatch:
jobs:
wait_for_docker_images:
name: Wait for docker images to be deployed
runs-on: ubuntu-22.04
steps:
- name: Wait for API image to be pushed to Docker Hub
uses: fountainhead/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: Push API Docker image to Azure Container Registry
ref: ${{ github.event.pull_request.head.sha || github.sha }}
intervalSeconds: 30
- name: Wait for Geoprocessing image to be pushed to Docker Hub
uses: fountainhead/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: Push Geoprocessing Docker image to Azure Container Registry
ref: ${{ github.event.pull_request.head.sha || github.sha }}
intervalSeconds: 30
- name: Wait for Client image to be pushed to Docker Hub
uses: fountainhead/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: Push Client Docker image to Azure Container Registry
ref: ${{ github.event.pull_request.head.sha || github.sha }}
intervalSeconds: 30
- name: Wait for Webshot image to be pushed to Docker Hub
uses: fountainhead/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: Push Webshot Docker image to Azure Container Registry
ref: ${{ github.event.pull_request.head.sha || github.sha }}
intervalSeconds: 30
deploy_images_to_kubernetes:
name: Deploy updated Docker image to Kubernetes
needs: wait_for_docker_images
runs-on: ubuntu-22.04
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Login via Azure CLI
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Configure SSH access to the bastion host
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/bastion.key
chmod 600 ~/.ssh/bastion.key
env:
SSH_KEY: ${{ secrets.BASTION_SSH_PRIVATE_KEY }}
- name: Add custom host data
run: |
sudo sh -c 'echo "127.0.0.1 ${{ vars.AZURE_AKS_HOST }}" >> /etc/hosts'
- name: Install kubectl
uses: azure/setup-kubectl@v4
with:
version: 'v1.25.16'
- name: Config kubectl
run: |
mkdir ~/.kube
az aks get-credentials --resource-group ${{ vars.AZURE_RESOURCE_GROUP }} --name ${{ vars.AZURE_AKS_CLUSTER_NAME }}
sed -i 's/\([[:alnum:]]\+\?.privatelink.[[:alnum:]]\+\?.azmk8s.io\):443/\1:4433/g' ~/.kube/config
- name: Creating SSH tunnel
run: |
ssh -i ~/.ssh/bastion.key -o StrictHostKeyChecking=no -N -L 4433:${{ vars.AZURE_AKS_HOST }}:443 ${{ vars.BASTION_USER }}@${{ vars.BASTION_HOST }} -T &
- name: Redeploy production pods
if: ${{ github.ref == 'refs/heads/main' }}
run: |
kubectl rollout restart deployment api -n production
kubectl rollout restart deployment client -n production
kubectl rollout restart deployment geoprocessing -n production
kubectl rollout restart deployment webshot -n production
- name: Redeploy staging pods
if: ${{ github.ref == 'refs/heads/staging' }}
run: |
kubectl rollout restart deployment api -n staging
kubectl rollout restart deployment client -n staging
kubectl rollout restart deployment geoprocessing -n staging
kubectl rollout restart deployment webshot -n staging