avisenna-landing-page/.github/workflows/build-and-deploy.yaml
2025-04-11 09:25:43 +00:00

50 lines
1.3 KiB
YAML

name: Build and Deploy to Kubernetes
on:
push:
branches: [ main ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Debug repository name
run: |
echo "Repository: ${{ github.repository }}"
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Docker Image
run: |
IMAGE_NAME="ghcr.io/${{ github.repository }}"
docker build -t "$IMAGE_NAME:latest" .
docker push "$IMAGE_NAME:latest"
shell: bash
- name: Set up Kubeconfig
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG_BASE64 }}" | base64 -d > ~/.kube/config
chmod 600 ~/.kube/config
export KUBECONFIG=~/.kube/config
kubectl version --short
shell: bash
- name: Deploy to Kubernetes
run: |
export KUBECONFIG=~/.kube/config
IMAGE_NAME="ghcr.io/${{ github.repository }}"
kubectl set image deployment/homepage homepage=$IMAGE_NAME:latest -n web
shell: bash