Compare commits
10 Commits
9a61a014ec
...
5e386d7df8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e386d7df8 | ||
|
|
5ac08324f2 | ||
|
|
30a3bcc955 | ||
|
|
8b7b90f0c2 | ||
|
|
dc0124a3cf | ||
|
|
bf6ab2aca3 | ||
|
|
dbe1dfa9d6 | ||
|
|
5bc7ef3745 | ||
|
|
06b9a3a3ec | ||
|
|
8a34e2c463 |
@@ -4,38 +4,55 @@ on: [push]
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # Получаем полную историю для корректного хеша
|
||||
|
||||
- name: Build and push with Kaniko (FIXED TAGS)
|
||||
- name: Get commit SHA (full)
|
||||
id: vars
|
||||
run: |
|
||||
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
echo "sha_full=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and push with Kaniko
|
||||
uses: aevea/action-kaniko@master
|
||||
with:
|
||||
registry: harbor.apps.kopikopi.com.ru
|
||||
username: ${{ secrets.HARBOR_USERNAME }}
|
||||
password: ${{ secrets.HARBOR_PASSWORD }}
|
||||
image: drone/test
|
||||
tags: main,latest,${{ gitea.sha }} # Добавляем main и latest
|
||||
tag: ${{ steps.vars.outputs.sha_short }} # Только короткий хеш
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
cache: true
|
||||
cache-repo: harbor.apps.kopikopi.com.ru/proxy/cache
|
||||
extra-args: |
|
||||
--label "org.label-schema.vcs-ref=${{ steps.vars.outputs.sha_full }}"
|
||||
--label "org.label-schema.build-date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
|
||||
- name: Update team-infra repository
|
||||
- name: Update infrastructure repository
|
||||
run: |
|
||||
# Клонируем ПРАВИЛЬНЫЙ репозиторий team-infra
|
||||
# Клонируем инфра-репозиторий
|
||||
git clone https://${{ secrets.USER }}:${{ secrets.GITEA }}@gitea.apps.kopikopi.com.ru/examples/nginx-intrasture.git
|
||||
cd nginx-intrasture
|
||||
cd nginx-intrasture/apps/static-site
|
||||
|
||||
# Обновляем тег образа на main
|
||||
sed -i "s|image:.*drone/test:.*|image: harbor.apps.kopikopi.com.ru/drone/test:main|g" apps/static-site/deployment.yaml
|
||||
# Простое решение: используем sed для изменения deployment.yaml
|
||||
NEW_IMAGE="harbor.apps.kopikopi.com.ru/drone/test:${{ steps.vars.outputs.sha_short }}"
|
||||
|
||||
# Коммитим и пушим
|
||||
# Обновляем deployment.yaml
|
||||
sed -i "s|image:.*drone/test:.*|image: $NEW_IMAGE|g" deployment.yaml
|
||||
|
||||
# Проверяем изменение
|
||||
echo "Updated deployment.yaml:"
|
||||
grep image deployment.yaml
|
||||
|
||||
# Коммитим изменения
|
||||
git config user.name "CI/CD Bot"
|
||||
git config user.email "ci-cd@kopikopi.com.ru"
|
||||
git add .
|
||||
git commit -m "Update static-site image to main"
|
||||
git push
|
||||
env:
|
||||
GITEA_USER: ${{ secrets.USER }}
|
||||
GITEA_TOKEN: ${{ secrets.GITEA }}
|
||||
git add deployment.yaml
|
||||
git commit -m "Update image to ${{ steps.vars.outputs.sha_short }}"
|
||||
git push
|
||||
24
ingress.yaml
24
ingress.yaml
@@ -1,24 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: nginx-test
|
||||
annotations:
|
||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||
nginx.ingress.kubernetes.io/rewrite-target: /
|
||||
spec:
|
||||
ingressClassName: nginx
|
||||
tls:
|
||||
- hosts:
|
||||
- nginx-test.apps.kopikopi.com.ru
|
||||
secretName: nginx-test-tls
|
||||
rules:
|
||||
- host: nginx-test.apps.kopikopi.com.ru
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: nginx-test
|
||||
port:
|
||||
number: 80
|
||||
@@ -1,6 +0,0 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
resources:
|
||||
- nginx-deployment.yaml
|
||||
- service.yaml
|
||||
- ingress.yaml
|
||||
@@ -1,19 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nginx-test
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nginx-test
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx-test
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx:alpine
|
||||
ports:
|
||||
- containerPort: 80
|
||||
@@ -2,7 +2,6 @@
|
||||
<html>
|
||||
<head><title>World</title></head>
|
||||
<body>
|
||||
<h1>🚀 Hello from GitOps!</h1>
|
||||
<p>Deployed via Argo CD. Commit SHA: {{ .Commit }}</p>
|
||||
<h1>hello world 2</h1>
|
||||
</body>
|
||||
</html>
|
||||
10
service.yaml
10
service.yaml
@@ -1,10 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: nginx-test
|
||||
spec:
|
||||
selector:
|
||||
app: nginx-test
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
Reference in New Issue
Block a user