Skip to content

wording

wording #117

Workflow file for this run

name: Deploy
on:
push:
branches: [ main ]
paths:
- 'apps/**'
- 'infra/k8s/apps/*-deployment.yaml'
- '.github/workflows/deploy-apps.yml'
workflow_dispatch:
jobs:
discover-apps:
runs-on: ubuntu-latest
outputs:
apps: ${{ steps.set-apps.outputs.apps }}
steps:
- uses: actions/checkout@v4
- name: Discover apps from deployment files
id: set-apps
run: |
apps=$(ls infra/k8s/apps/*-deployment.yaml | xargs -n1 basename | sed 's/-deployment.yaml//' | jq -R -s -c 'split("\n")[:-1]')
echo "apps=$apps" >> $GITHUB_OUTPUT
echo "Discovered apps: $apps"
deploy:
needs: discover-apps
runs-on: ubuntu-latest
strategy:
matrix:
app: ${{ fromJson(needs.discover-apps.outputs.apps) }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup kubectl
uses: azure/setup-kubectl@v4
- name: Configure kubeconfig
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBE_CONFIG }}" > ~/.kube/config
chmod 600 ~/.kube/config
- name: Detect namespace from manifest
id: detect-namespace
run: |
namespace=$(grep -A 5 "kind: Deployment" infra/k8s/apps/${{ matrix.app }}-deployment.yaml | grep "namespace:" | head -1 | awk '{print $2}' || echo "default")
if [ -z "$namespace" ]; then
namespace="default"
fi
echo "namespace=$namespace" >> $GITHUB_OUTPUT
echo "Detected namespace: $namespace"
- name: Apply K8s manifests
run: kubectl apply -f infra/k8s/apps/${{ matrix.app }}-deployment.yaml
- name: Check if app has custom image
id: check-image
run: |
if [[ "${{ matrix.app }}" == "headlamp"* ]]; then
echo "has_custom_image=false" >> $GITHUB_OUTPUT
echo "App uses external image, skipping image update"
else
echo "has_custom_image=true" >> $GITHUB_OUTPUT
echo "App has custom image, will update"
fi
- name: Set commit SHA env
if: steps.check-image.outputs.has_custom_image == 'true'
run: |
kubectl set env deployment/${{ matrix.app }} -n ${{ steps.detect-namespace.outputs.namespace }} COMMIT_SHA=${{ github.sha }}
- name: Update deployment image to current SHA
if: steps.check-image.outputs.has_custom_image == 'true'
run: |
kubectl set image deployment/${{ matrix.app }} ${{ matrix.app }}=ghcr.io/${{ github.repository_owner }}/${{ matrix.app }}:sha-${{ github.sha }} -n ${{ steps.detect-namespace.outputs.namespace }}
- name: Wait for rollout
run: kubectl rollout status deployment/${{ matrix.app }} -n ${{ steps.detect-namespace.outputs.namespace }}