cicd
Some checks are pending
CI/CD Pipeline / build-and-push (push) Waiting to run

This commit is contained in:
ITO Mac
2026-04-14 11:02:09 +02:00
parent 1261b2ad1e
commit 37243df9aa
8 changed files with 241 additions and 2 deletions

55
.gitea/workflows/ci.yaml Normal file
View File

@@ -0,0 +1,55 @@
name: CI/CD Pipeline
on:
push:
branches: [main]
env:
REGISTRY: git.fpmoz.sum.ba
IMAGE_NAME: blazp04/distribuirani
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout koda
uses: actions/checkout@v4
- name: Postavi Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Prijava na Gitea Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Generiraj tagove za image
id: meta
run: |
SHORT_SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
echo "short_sha=${SHORT_SHA}" >> "$GITHUB_OUTPUT"
echo "tags=${REGISTRY}/${IMAGE_NAME}:${SHORT_SHA},${REGISTRY}/${IMAGE_NAME}:latest" >> "$GITHUB_OUTPUT"
- name: Build i push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
cache-to: type=inline
- name: Ažuriraj image tag u deployment manifestu
run: |
SHORT_SHA=${{ steps.meta.outputs.short_sha }}
sed -i "s|image: ${REGISTRY}/${IMAGE_NAME}:.*|image: ${REGISTRY}/${IMAGE_NAME}:${SHORT_SHA}|" k8s/distribuirani/deployment.yaml
cat k8s/distribuirani/deployment.yaml
- name: Commit i push ažuriranog manifesta
run: |
git config user.name "Gitea Actions"
git config user.email "actions@git.fpmoz.sum.ba"
git add k8s/distribuirani/deployment.yaml
git diff --cached --quiet && echo "Nema promjena" || (git commit -m "ci: update image tag to ${{ steps.meta.outputs.short_sha }} [skip ci]" && git push)