Compare commits
No commits in common. "84902d211eda406f0360326e4bad5d3021fb71d5" and "75523a50d044d813756b1673f34d93e2d33739e1" have entirely different histories.
84902d211e
...
75523a50d0
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches: [ main ] # Apenas quando merge na main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
@ -10,79 +10,35 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
run: |
|
uses: actions/checkout@v4
|
||||||
echo "✅ Checking workspace directory structure"
|
|
||||||
pwd
|
- name: Setup .NET
|
||||||
echo "Root files:"
|
uses: actions/setup-dotnet@v4
|
||||||
ls -la
|
with:
|
||||||
echo "YTExtractor folder contents:"
|
dotnet-version: '8.0.x' # ou sua versão
|
||||||
ls -la YTExtractor/ || echo "YTExtractor folder not found"
|
|
||||||
echo "Looking for .sln files..."
|
|
||||||
find . -name "*.sln" -type f
|
|
||||||
echo "Looking for Dockerfile..."
|
|
||||||
find . -name "Dockerfile" -type f
|
|
||||||
|
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: |
|
run: dotnet restore
|
||||||
echo "Navigating to YTExtractor directory and restoring..."
|
|
||||||
cd YTExtractor
|
|
||||||
ls -la
|
|
||||||
dotnet restore
|
|
||||||
|
|
||||||
- name: Build application
|
- name: Build application
|
||||||
run: |
|
run: dotnet build --configuration Release --no-restore
|
||||||
echo "Building from YTExtractor directory..."
|
|
||||||
cd YTExtractor
|
|
||||||
dotnet build --configuration Release --no-restore
|
|
||||||
|
|
||||||
- name: Run tests (opcional)
|
- name: Run tests (opcional)
|
||||||
run: |
|
run: dotnet test --no-build --verbosity normal
|
||||||
echo "Running tests from YTExtractor directory..."
|
|
||||||
cd YTExtractor
|
|
||||||
dotnet test --no-build --verbosity normal || true
|
|
||||||
|
|
||||||
- name: Publish application
|
- name: Publish application
|
||||||
run: |
|
run: dotnet publish --configuration Release --output ./publish
|
||||||
echo "Publishing from YTExtractor directory..."
|
|
||||||
cd YTExtractor
|
|
||||||
dotnet publish --configuration Release --output ../publish
|
|
||||||
|
|
||||||
- name: Build Docker image
|
- name: Build Docker image
|
||||||
run: |
|
run: |
|
||||||
echo "Current directory: $(pwd)"
|
docker build -t ytextractor:${{ github.sha }} .
|
||||||
echo "Files in current directory:"
|
docker tag ytextractor:${{ github.sha }} registry.redecarneir.us/ytextractor:latest
|
||||||
ls -la
|
docker tag ytextractor:${{ github.sha }} registry.redecarneir.us/ytextractor:${{ github.sha }}
|
||||||
|
|
||||||
COMMIT_SHA=$(git rev-parse --short HEAD)
|
|
||||||
|
|
||||||
# Verificar onde está o Dockerfile
|
|
||||||
if [ -f "YTExtractor/Dockerfile" ]; then
|
|
||||||
echo "✅ Found Dockerfile in YTExtractor directory"
|
|
||||||
cd YTExtractor
|
|
||||||
echo "Building Docker image from YTExtractor directory..."
|
|
||||||
docker build -t ytextractor:$COMMIT_SHA .
|
|
||||||
elif [ -f "Dockerfile" ]; then
|
|
||||||
echo "✅ Found Dockerfile in root directory"
|
|
||||||
echo "Building Docker image from root..."
|
|
||||||
docker build -t ytextractor:$COMMIT_SHA .
|
|
||||||
else
|
|
||||||
echo "❌ Dockerfile not found!"
|
|
||||||
find . -name "Dockerfile" -type f
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Tag das imagens
|
|
||||||
docker tag ytextractor:$COMMIT_SHA registry.redecarneir.us/ytextractor:latest
|
|
||||||
docker tag ytextractor:$COMMIT_SHA registry.redecarneir.us/ytextractor:$COMMIT_SHA
|
|
||||||
|
|
||||||
echo "✅ Docker images built successfully"
|
|
||||||
docker images | grep ytextractor
|
|
||||||
|
|
||||||
- name: Push to registry
|
- name: Push to registry
|
||||||
run: |
|
run: |
|
||||||
COMMIT_SHA=$(git rev-parse --short HEAD)
|
|
||||||
docker push registry.redecarneir.us/ytextractor:latest
|
docker push registry.redecarneir.us/ytextractor:latest
|
||||||
docker push registry.redecarneir.us/ytextractor:$COMMIT_SHA
|
docker push registry.redecarneir.us/ytextractor:${{ github.sha }}
|
||||||
|
|
||||||
- name: Deploy to remote VPS
|
- name: Deploy to remote VPS
|
||||||
run: |
|
run: |
|
||||||
@ -95,24 +51,17 @@ jobs:
|
|||||||
docker rm ytextractor-api || true
|
docker rm ytextractor-api || true
|
||||||
|
|
||||||
# Rodar novo container em produção
|
# Rodar novo container em produção
|
||||||
# Porta 80 interna (do container) mapeada para 5000 externa
|
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name ytextractor-api \
|
--name ytextractor-api \
|
||||||
--restart unless-stopped \
|
--restart unless-stopped \
|
||||||
-p 5000:80 \
|
-p 5000:8080 \
|
||||||
-e ASPNETCORE_ENVIRONMENT=Production \
|
-e ASPNETCORE_ENVIRONMENT=Production \
|
||||||
-v /tmp/ytextractor:/app/temp \
|
|
||||||
registry.redecarneir.us/ytextractor:latest
|
registry.redecarneir.us/ytextractor:latest
|
||||||
|
|
||||||
# Verificar se está rodando
|
|
||||||
sleep 5
|
|
||||||
docker ps | grep ytextractor-api
|
|
||||||
|
|
||||||
# Limpeza de imagens antigas (opcional)
|
# Limpeza de imagens antigas (opcional)
|
||||||
docker image prune -f
|
docker image prune -f
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
- name: Verify deployment
|
- name: Verify deployment
|
||||||
run: |
|
run: |
|
||||||
ssh ubuntu@137.131.63.61 'docker ps | grep ytextractor-api'
|
ssh ubuntu@137.131.63.61 'docker ps | grep ytextractor-api'
|
||||||
echo "✅ Deploy completed successfully!"
|
|
||||||
Loading…
Reference in New Issue
Block a user