Files
play-life/.gitea/workflows/build-and-push.yml
poignatov b9133f60dc
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 36s
Bump version to 3.4.0 and add Telegram notifications to CI
2026-01-07 15:06:58 +03:00

98 lines
3.5 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Build and Push Docker Image
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest # Убедитесь, что у вашего раннера есть этот тег
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get versions and check change
id: version_check
run: |
# Извлекаем текущую версию
CUR=$(cat VERSION | tr -d '[:space:]')
echo "current=$CUR" >> $GITHUB_OUTPUT
# Безопасно извлекаем старую версию
PREV=$(git show HEAD~1:VERSION 2>/dev/null | tr -d '[:space:]' || echo "none")
if [ "$CUR" != "$PREV" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Patch DNS for Local Network
if: steps.version_check.outputs.changed == 'true'
run: |
# Записываем IP Synology прямо в контейнер сборки
echo "192.168.50.55 dungeonsiege.synology.me" | sudo tee -a /etc/hosts
- name: Log in to Gitea Registry
if: steps.version_check.outputs.changed == 'true'
run: |
echo "${{ secrets.GIT_TOKEN }}" | docker login dungeonsiege.synology.me -u ${{ secrets.GIT_USERNAME }} --password-stdin
- name: Build and Push
id: build
if: steps.version_check.outputs.changed == 'true'
run: |
REGISTRY="dungeonsiege.synology.me/poignatov/play-life"
VER="${{ steps.version_check.outputs.current }}"
# Собираем один раз
docker build -t $REGISTRY:latest -t $REGISTRY:$VER .
# Пушим оба тега
docker push $REGISTRY:latest
docker push $REGISTRY:$VER
- name: Send Telegram notification (success)
if: success() && steps.version_check.outputs.changed == 'true'
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
✅ Сборка успешна!
Проект: play-life
Версия: ${{ steps.version_check.outputs.current }}
Ветка: ${{ github.ref_name }}
Коммит: ${{ github.sha }}
- name: Send Telegram notification (failure)
if: failure()
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
❌ Сборка завершилась с ошибкой!
Проект: play-life
Версия: ${{ steps.version_check.outputs.current }}
Ветка: ${{ github.ref_name }}
Коммит: ${{ github.sha }}
- name: Send Telegram notification (skipped)
if: steps.version_check.outputs.changed == 'false'
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
Сборка пропущена
Проект: play-life
Версия не изменилась: ${{ steps.version_check.outputs.current }}
Ветка: ${{ github.ref_name }}