Files
nginx/.gitea/workflows/test.yaml
samsep101 dbe1dfa9d6 bun init
2026-01-05 15:47:39 +05:00

58 lines
2.5 KiB
YAML

name: Build with Kaniko and Deploy
on: [push]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Получаем полную историю для корректного хеша
- 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
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 infrastructure with Kustomize
run: |
# Клонируем инфра-репозиторий
git clone https://${{ secrets.USER }}:${{ secrets.GITEA }}@gitea.apps.kopikopi.com.ru/examples/nginx-intrasture.git
cd nginx-intrasture/apps/static-site
# Устанавливаем Kustomize
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
# Обновляем тег образа через Kustomize (самый надежный способ)
./kustomize edit set image drone/test=harbor.apps.kopikopi.com.ru/drone/test:${{ steps.vars.outputs.sha_short }}
# Альтернатива: используем yq для точного редактирования
# wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O yq
# chmod +x yq
# ./yq eval -i '.images[0].newTag = "${{ steps.vars.outputs.sha_short }}"' kustomization.yaml
# Коммитим и пушим
git config user.name "CI/CD Bot"
git config user.email "ci-cd@kopikopi.com.ru"
git add kustomization.yaml
git commit -m "Update image to ${{ steps.vars.outputs.sha_short }}"
git push