Build and deploy a Docker image to Kubernetes
Steps:
- Build the image
- Push the image to GitHub Container Registry (GHCR)
- Apply deployment to the Kubernetes cluster
Example:
# .github/workflows/deploy.yml
name: Build image and deploy to kubernetes
on:
push:
branches: [ "main" ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: .
- uses: feavy/deploy@main
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
GITHUB_USERNAME: feavy
GITHUB_TOKEN: ${{ secrets.PAT }}
DOCKERFILE_PATH: .
DOCKER_IMAGE: feavy-nginx:latest
DEPLOYMENT: deployment.yml
PLATFORM: arm64 # amd64 by default
# Manually restart deployment if needed:
- name: Restart deployment
run: kubectl rollout restart deployment feavy-nginx