Files
play-life/.gitea/workflows/build-and-push.yml
poignatov 6dbb0f8d90
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m11s
Обновление gitea workflow: сборка всегда
2026-01-27 19:40:09 +03:00

121 lines
4.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
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
# Извлекаем сообщение последнего коммита
COMMIT_MSG=$(git log -1 --pretty=%B | head -1)
echo "commit_message=$COMMIT_MSG" >> $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
run: |
# Записываем IP Synology прямо в контейнер сборки
echo "192.168.50.55 dungeonsiege.synology.me" | sudo tee -a /etc/hosts
- name: Build Docker Image
id: build
run: |
REGISTRY="dungeonsiege.synology.me/poignatov/play-life"
VER="${{ steps.version_check.outputs.current }}"
echo "Building Docker image..."
echo "Registry: $REGISTRY"
echo "Tag: latest"
# Собираем образ
docker build -t $REGISTRY:latest .
echo "✅ Successfully built image: $REGISTRY:latest"
- 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: Push Docker Image
if: steps.version_check.outputs.changed == 'true'
run: |
REGISTRY="dungeonsiege.synology.me/poignatov/play-life"
VER="${{ steps.version_check.outputs.current }}"
# Тегируем образ версией
docker tag $REGISTRY:latest $REGISTRY:$VER
# Пушим оба тега
echo "Pushing image to registry..."
docker push $REGISTRY:latest
docker push $REGISTRY:$VER
echo "✅ Successfully pushed to registry:"
echo " - $REGISTRY:latest"
echo " - $REGISTRY:$VER"
- name: Send Telegram notification (build success)
if: success() && steps.version_check.outputs.changed == 'false'
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: |
**play-life**
*${{ steps.version_check.outputs.commit_message }}*
Сборка: ✅
Публикация: ⏭️
- name: Send Telegram notification (publish success)
if: success() && steps.version_check.outputs.changed == 'true'
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: |
**play-life**
*${{ steps.version_check.outputs.commit_message }}*
Сборка: ✅
Публикация: ✅
- name: Send Telegram notification (failure)
if: failure()
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: |
**play-life**
*${{ steps.version_check.outputs.commit_message }}*
Сборка: ❌
Публикация: ❌