Compare commits
5 Commits
ba683efa9e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5f64d827b | ||
|
|
9d98f5b466 | ||
|
|
87d5da322f | ||
|
|
f983fa2ecc | ||
|
|
43f87f1e72 |
@@ -9,7 +9,6 @@ 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: ubuntu-latest
|
||||||
@@ -18,14 +17,20 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Login u Gitea registry
|
- name: Login u Gitea registry
|
||||||
run: echo "${{ secrets.REGISTRY_PASS }}" | docker login ${{ env.REGISTRY }} -u ${{ secrets.REGISTRY_USER }} --password-stdin
|
run: |
|
||||||
|
echo ${{ secrets.REGISTRY_PASS }} | \
|
||||||
|
docker login $REGISTRY \
|
||||||
|
-u ${{ secrets.REGISTRY_USER }} --password-stdin
|
||||||
|
|
||||||
- name: Build i Push image
|
- name: Build i Push image
|
||||||
run: |
|
run: |
|
||||||
TAG=${{ github.sha }}
|
TAG=${{ github.sha }}
|
||||||
docker build -t $IMAGE:$TAG -t $IMAGE:latest .
|
IMAGE_LC=$(echo "$IMAGE" | tr '[:upper:]' '[:lower:]')
|
||||||
docker push $IMAGE:$TAG
|
|
||||||
docker push $IMAGE:latest
|
docker build -t $IMAGE_LC:$TAG -t $IMAGE_LC:latest .
|
||||||
|
docker push $IMAGE_LC:$TAG
|
||||||
|
docker push $IMAGE_LC:latest
|
||||||
|
|
||||||
echo $TAG > tag.txt
|
echo $TAG > tag.txt
|
||||||
|
|
||||||
- name: Spremi image tag
|
- name: Spremi image tag
|
||||||
@@ -47,18 +52,31 @@ jobs:
|
|||||||
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
|
||||||
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > ~/.kube/config
|
cat <<'EOF' > ~/.kube/config.base64
|
||||||
|
${{ secrets.KUBE_CONFIG }}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
|
||||||
|
tr -d '[:space:]' < ~/.kube/config.base64 | base64 -d > ~/.kube/config
|
||||||
chmod 600 ~/.kube/config
|
chmod 600 ~/.kube/config
|
||||||
|
|
||||||
- name: Update image tag u manifestu
|
- name: Update image tag u manifestu
|
||||||
run: |
|
run: |
|
||||||
TAG=$(cat tag.txt)
|
TAG=$(cat tag.txt)
|
||||||
sed -i "s|image:.*|image: $IMAGE:$TAG|" k8s/deployment.yaml
|
IMAGE_LC=$(echo "$IMAGE" | tr '[:upper:]' '[:lower:]')
|
||||||
|
sed -i "s|image:.*|image: $IMAGE_LC:$TAG|" k8s/deployment.yaml
|
||||||
|
|
||||||
- name: Deploy na k3s
|
- name: Deploy na k3s
|
||||||
run: |
|
run: |
|
||||||
kubectl apply -f k8s/
|
kubectl apply -f k8s/ -n student-ivanivso7
|
||||||
kubectl rollout status deployment/hello-cicd -n student-${{ github.actor }} --timeout=120s
|
kubectl rollout status deployment/hello-cicd \
|
||||||
|
-n student-ivanivso7 --timeout=120s
|
||||||
@@ -23,7 +23,7 @@ spec:
|
|||||||
- containerPort: 8000
|
- containerPort: 8000
|
||||||
env:
|
env:
|
||||||
- name: APP_VERSION
|
- name: APP_VERSION
|
||||||
value: "latest"
|
value: "v2.0"
|
||||||
resources:
|
resources:
|
||||||
requests: {cpu: 50m, memory: 64Mi}
|
requests: {cpu: 50m, memory: 64Mi}
|
||||||
limits: {cpu: 200m, memory: 128Mi}
|
limits: {cpu: 200m, memory: 128Mi}
|
||||||
|
|||||||
Reference in New Issue
Block a user