avisenna-landing-page/.github/workflows/build-and-deploy.yaml
2025-04-11 18:32:33 +00:00

48 lines
1.2 KiB
YAML

name: Build and Deploy
on:
push:
branches:
- main
- dev
- 'feat/**'
- 'test/**'
- 'fix/**'
- 'hotfix/**'
env:
VERSION: ${{ vars.VERSION || 'latest' }}
NAMESPACE: ${{ github.ref == 'refs/heads/main' && 'prod' || 'web' }}
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
run: |
IMAGE_NAME="ghcr.io/${{ github.repository }}:$VERSION"
docker build -t $IMAGE_NAME .
docker push $IMAGE_NAME
- name: Set up kubeconfig from secret
run: |
mkdir -p $HOME/.kube
echo "${{ secrets.KUBECONFIG_BASE64 }}" | base64 -d > $HOME/.kube/config
shell: bash
- name: Deploy to Kubernetes
run: |
IMAGE="ghcr.io/${{ github.repository }}:$VERSION"
kubectl set image deployment/homepage home=$IMAGE -n $NAMESPACE
shell: bash