feat: implements a better kubernetes deployment setup
This commit is contained in:
@@ -2,6 +2,12 @@ name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Tag to deploy'
|
||||
required: false
|
||||
default: 'latest'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -69,4 +75,34 @@ jobs:
|
||||
- name: Push Docker images
|
||||
run: |
|
||||
docker push $IMAGE_LATEST
|
||||
docker push $IMAGE_SHA
|
||||
docker push $IMAGE_SHA
|
||||
|
||||
deploy:
|
||||
needs: [docker]
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' && (github.ref == 'refs/heads/main')
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Kubeconfig
|
||||
uses: azure/setup-kubectl@v3
|
||||
with:
|
||||
method: kubeconfig
|
||||
kubeconfig: ${{ secrets.PORTFOLIO_KUBECONFIG }}
|
||||
|
||||
- name: Deploy to Kubernetes
|
||||
run: |
|
||||
OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')
|
||||
REPO=$(echo "${GITHUB_REPOSITORY#*/}" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
IMAGE_BASE="ghcr.io/${OWNER}/${REPO}"
|
||||
TAG="${{ github.event.inputs.tag || 'latest' }}"
|
||||
|
||||
kubectl config set-context --current --namespace=$KUBE_NAMESPACE
|
||||
|
||||
# Apply any other configuration changes if needed
|
||||
envsubst < .k8s/config.yml | kubectl apply -f -
|
||||
envsubst < .k8s/deployment.yaml | kubectl apply -f -
|
||||
envsubst < .k8s/service.yaml | kubectl apply -f -
|
||||
envsubst < .k8s/ingress.yaml | kubectl apply -f -
|
||||
Reference in New Issue
Block a user