Ispravka
This commit is contained in:
@@ -1,70 +0,0 @@
|
|||||||
name: CI/CD Pipeline
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: git.fpmoz.sum.ba
|
|
||||||
IMAGE: git.fpmoz.sum.ba/${{ github.repository }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
|
|
||||||
# ── JOB 1: Build i Push Docker image ──────────────────
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
|
|
||||||
- name: Checkout koda
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Login u Gitea registry
|
|
||||||
run: |
|
|
||||||
echo ${{ secrets.REGISTRY_PASS }} | \
|
|
||||||
docker login $REGISTRY \
|
|
||||||
-u ${{ secrets.REGISTRY_USER }} --stdin
|
|
||||||
|
|
||||||
- name: Build i Push image
|
|
||||||
run: |
|
|
||||||
TAG=${{ github.sha }}
|
|
||||||
docker build -t $IMAGE:$TAG -t $IMAGE:latest .
|
|
||||||
docker push $IMAGE:$TAG
|
|
||||||
docker push $IMAGE:latest
|
|
||||||
echo $TAG > tag.txt
|
|
||||||
|
|
||||||
- name: Spremi image tag
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: image-tag
|
|
||||||
path: tag.txt
|
|
||||||
# ── JOB 2: Deploy na k3s ───────────────────────────────
|
|
||||||
deploy:
|
|
||||||
needs: build
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
|
|
||||||
- name: Checkout koda
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Preuzmi image tag
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: image-tag
|
|
||||||
|
|
||||||
- name: Postavi kubeconfig
|
|
||||||
run: |
|
|
||||||
mkdir -p ~/.kube
|
|
||||||
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > ~/.kube/config
|
|
||||||
chmod 600 ~/.kube/config
|
|
||||||
|
|
||||||
- name: Update image tag u manifestu
|
|
||||||
run: |
|
|
||||||
TAG=$(cat tag.txt)
|
|
||||||
sed -i "s|image:.*|image: $IMAGE:$TAG|" k8s/deployment.yaml
|
|
||||||
|
|
||||||
- name: Deploy na k3s
|
|
||||||
run: |
|
|
||||||
kubectl apply -f k8s/
|
|
||||||
kubectl rollout status deployment/hello-cicd \
|
|
||||||
-n student-${{ github.actor }} --timeout=120s
|
|
||||||
|
|
||||||
@@ -2,23 +2,23 @@
|
|||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: hello-cicd
|
name: helloo-cicdd
|
||||||
namespace: student-marijanela218
|
namespace: student-marijanela218
|
||||||
spec:
|
spec:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: hello-cicd
|
app: helloo-cicdd
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: hello-cicd
|
app: helloo-cicdd
|
||||||
spec:
|
spec:
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: gitea-creds
|
- name: gitea-creds
|
||||||
containers:
|
containers:
|
||||||
- name: hello-cicd
|
- name: helloo-cicdd
|
||||||
image: git.fpmoz.sum.ba/Marijanela218/hello-cicd:latest
|
image: git.fpmoz.sum.ba/Marijanela218/helloo-cicdd:latest
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8000
|
- containerPort: 8000
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: hello-cicd-svc
|
name: helloo-cicdd-svc
|
||||||
namespace: student-marijanela218
|
namespace: student-marijanela218
|
||||||
spec:
|
spec:
|
||||||
selector:
|
selector:
|
||||||
app: hello-cicd
|
app: helloo-cicdd
|
||||||
ports:
|
ports:
|
||||||
- port: 80
|
- port: 80
|
||||||
targetPort: 8000
|
targetPort: 8000
|
||||||
|
|||||||
Reference in New Issue
Block a user