ci: add CI/CD workflow
Some checks failed
CI/CD Pipeline / build (push) Failing after 3s
CI/CD Pipeline / deploy (push) Failing after 26s

This commit is contained in:
Ivan Filipovic
2026-04-20 20:48:00 +02:00
parent 602378ac97
commit 2b569f38c5

View File

@@ -10,10 +10,12 @@ env:
IMAGE: git.fpmoz.sum.ba/${{ github.repository }} IMAGE: git.fpmoz.sum.ba/${{ github.repository }}
jobs: jobs:
# ── JOB 1: Build i Push Docker image ────────────────── # ── JOB 1: Build i Push Docker image ──────────────────
build: build:
runs-on: ubuntu-latest runs-on: self-hosted
steps: steps:
- name: Checkout koda - name: Checkout koda
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -21,7 +23,7 @@ jobs:
run: | run: |
echo ${{ secrets.REGISTRY_PASS }} | \ echo ${{ secrets.REGISTRY_PASS }} | \
docker login $REGISTRY \ docker login $REGISTRY \
-u ${{ secrets.REGISTRY_USER }} --password-stdin -u ${{ secrets.REGISTRY_USER }} --stdin
- name: Build i Push image - name: Build i Push image
run: | run: |
@@ -32,30 +34,24 @@ jobs:
echo $TAG > tag.txt echo $TAG > tag.txt
- name: Spremi image tag - name: Spremi image tag
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: image-tag name: image-tag
path: tag.txt path: tag.txt
# ── JOB 2: Deploy na k3s ─────────────────────────────── # ── JOB 2: Deploy na k3s ───────────────────────────────
deploy: deploy:
needs: build needs: buil
runs-on: ubuntu-latest runs-on: self-hosted
steps: steps:
- name: Checkout koda - name: Checkout koda
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Preuzmi image tag - name: Preuzmi image tag
uses: actions/download-artifact@v3 uses: actions/download-artifact@v4
with: with:
name: image-tag name: image-tag
- name: Instaliraj kubectl
run: |
curl -LO "https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
mv kubectl /usr/local/bin/
- name: Postavi kubeconfig - name: Postavi kubeconfig
run: | run: |
mkdir -p ~/.kube mkdir -p ~/.kube
@@ -69,7 +65,6 @@ jobs:
- name: Deploy na k3s - name: Deploy na k3s
run: | run: |
kubectl create namespace student-${{ github.actor }} --dry-run=client -o yaml | kubectl apply -f - kubectl apply -f k8s/
kubectl apply -f k8s/ -n student-${{ github.actor }}
kubectl rollout status deployment/hello-cicd \ kubectl rollout status deployment/hello-cicd \
-n student-${{ github.actor }} --timeout=120s -n student-${{ github.actor }} --timeout=120s