Agent: "Create GitHub Actions workflow for Kubernetes:
- Deploy to multiple environments
# .github/workflows/deploy.yml
name: Deploy to Kubernetes
branches: [main, develop]
IMAGE_NAME: ${{ github.repository }}
image-tag: ${{ steps.meta.outputs.tags }}
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to registry
uses: docker/login-action@v3
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
uses: docker/metadata-action@v5
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
type=semver,pattern={{version}}
uses: docker/build-push-action@v5
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-to: type=gha,mode=max
if: github.ref == 'refs/heads/develop'
uses: actions/checkout@v4
repository: myorg/k8s-configs
token: ${{ secrets.CONFIG_REPO_TOKEN }}
cd applications/my-app/overlays/staging
kustomize edit set image backend=${{ needs.build.outputs.image-tag }}
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git commit -m "Update staging image to ${{ needs.build.outputs.image-tag }}"
- name: Wait for ArgoCD sync
# Wait for ArgoCD to sync and deploy
kubectl run smoke-test --image=curlimages/curl:latest --rm -i --restart=Never -- \
curl -f https://staging-api.example.com/health
needs: [build, deploy-staging]
if: github.ref == 'refs/heads/main'
uses: actions/checkout@v4
repository: myorg/k8s-configs
token: ${{ secrets.CONFIG_REPO_TOKEN }}
cd applications/my-app/overlays/production
kustomize edit set image backend=${{ needs.build.outputs.image-tag }}
uses: peter-evans/create-pull-request@v5
token: ${{ secrets.CONFIG_REPO_TOKEN }}
commit-message: "Deploy ${{ needs.build.outputs.image-tag }} to production"
title: "Deploy ${{ needs.build.outputs.image-tag }} to production"
Automated deployment of ${{ needs.build.outputs.image-tag }} to production.
- Built from: ${{ github.sha }}
- Triggered by: @${{ github.actor }}
branch: deploy-${{ github.sha }}