bun init
This commit is contained in:
@@ -8,6 +8,14 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
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
|
- name: Build and push with Kaniko
|
||||||
uses: aevea/action-kaniko@master
|
uses: aevea/action-kaniko@master
|
||||||
@@ -16,26 +24,35 @@ jobs:
|
|||||||
username: ${{ secrets.HARBOR_USERNAME }}
|
username: ${{ secrets.HARBOR_USERNAME }}
|
||||||
password: ${{ secrets.HARBOR_PASSWORD }}
|
password: ${{ secrets.HARBOR_PASSWORD }}
|
||||||
image: drone/test
|
image: drone/test
|
||||||
tag: ${{ gitea.sha }} # Добавляем main и latest
|
tag: ${{ steps.vars.outputs.sha_short }} # Только короткий хеш
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
cache: true
|
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 with Kustomize
|
||||||
run: |
|
run: |
|
||||||
# Клонируем ПРАВИЛЬНЫЙ репозиторий team-infra
|
# Клонируем инфра-репозиторий
|
||||||
git clone https://${{ secrets.USER }}:${{ secrets.GITEA }}@gitea.apps.kopikopi.com.ru/examples/nginx-intrasture.git
|
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
|
# Устанавливаем Kustomize
|
||||||
sed -i "s|image:.*drone/test:.*|image: harbor.apps.kopikopi.com.ru/drone/test:main|g" apps/static-site/deployment.yaml
|
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.name "CI/CD Bot"
|
||||||
git config user.email "ci-cd@kopikopi.com.ru"
|
git config user.email "ci-cd@kopikopi.com.ru"
|
||||||
git add .
|
git add kustomization.yaml
|
||||||
git commit -m "Update static-site image to main"
|
git commit -m "Update image to ${{ steps.vars.outputs.sha_short }}"
|
||||||
git push
|
git push
|
||||||
env:
|
|
||||||
GITEA_USER: ${{ secrets.USER }}
|
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA }}
|
|
||||||
Reference in New Issue
Block a user