Skip to content

Auto Rebuild PHIVE Validator #1

Auto Rebuild PHIVE Validator

Auto Rebuild PHIVE Validator #1

Workflow file for this run

name: Auto Rebuild PHIVE Validator
on:
# Weekly rebuild - her Pazar gece 00:00 (UTC)
schedule:
- cron: '0 0 * * 0'
# Manuel trigger
workflow_dispatch:
# phive-rules güncelleme kontrolü (opsiyonel - external repo watch için webhook gerekir)
# repository_dispatch:
# types: [phive-rules-updated]
jobs:
check-and-rebuild:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Check phive-rules for updates
id: check-updates
run: |
# phive-rules son commit hash'ini kontrol et
LATEST_COMMIT=$(curl -s https://api.github.com/repos/phax/phive-rules/commits/master | jq -r '.sha')
echo "latest_commit=$LATEST_COMMIT" >> $GITHUB_OUTPUT
echo "Latest phive-rules commit: $LATEST_COMMIT"
# Son build edilen commit'i kontrol et (varsa)
if [ -f .last-build-commit ]; then
LAST_BUILD=$(cat .last-build-commit)
echo "Last build commit: $LAST_BUILD"
if [ "$LATEST_COMMIT" == "$LAST_BUILD" ]; then
echo "needs_rebuild=false" >> $GITHUB_OUTPUT
echo "✅ No updates needed - phive-rules unchanged"
else
echo "needs_rebuild=true" >> $GITHUB_OUTPUT
echo "🔄 Updates detected - rebuild needed"
fi
else
echo "needs_rebuild=true" >> $GITHUB_OUTPUT
echo "🆕 First build - no previous commit found"
fi
- name: Build and test Docker image
if: steps.check-updates.outputs.needs_rebuild == 'true'
run: |
echo "🔨 Building Docker image with latest phive-rules..."
docker compose build --no-cache
echo "✅ Build completed successfully!"
# Container'ı test et
echo "🧪 Testing container..."
docker compose up -d
sleep 30
# Health check
if curl -f http://localhost/api; then
echo "✅ Health check passed!"
else
echo "❌ Health check failed!"
docker compose logs
exit 1
fi
# Kaç modül yüklendi kontrol et
MODULES_LOADED=$(docker compose logs phive-doc-validator 2>&1 | grep -oP "Modules loaded: \K\d+")
echo "📊 Modules loaded: $MODULES_LOADED"
docker compose down
- name: Save build commit hash
if: steps.check-updates.outputs.needs_rebuild == 'true'
run: |
echo "${{ steps.check-updates.outputs.latest_commit }}" > .last-build-commit
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git add .last-build-commit
git commit -m "chore: update last build commit [skip ci]" || echo "No changes to commit"
git push || echo "Nothing to push"
- name: Create release tag (optional)
if: steps.check-updates.outputs.needs_rebuild == 'true'
run: |
TAG_NAME="v$(date +%Y%m%d-%H%M%S)"
git tag -a "$TAG_NAME" -m "Auto-rebuild with latest phive-rules"
git push origin "$TAG_NAME" || echo "Tag already exists"
echo "✅ Created tag: $TAG_NAME"
- name: Send notification (optional)
if: steps.check-updates.outputs.needs_rebuild == 'true'
run: |
echo "🔔 Rebuild completed successfully!"
echo "Latest phive-rules commit: ${{ steps.check-updates.outputs.latest_commit }}"
# Buraya Slack/Discord/Email notification eklenebilir