Merge pull request 'fix: pipeline' (#4) from release/V1.0.0 into main
Some checks failed
Build and Deploy ASP.NET API / build-and-deploy (push) Failing after 0s
Some checks failed
Build and Deploy ASP.NET API / build-and-deploy (push) Failing after 0s
Reviewed-on: http://git.carneiro.ddnsfree.com/ricardo/YTExtractor/pulls/4
This commit is contained in:
commit
84902d211e
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ] # Apenas quando merge na main
|
branches: [ main ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
@ -10,35 +10,79 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
run: |
|
||||||
|
echo "✅ Checking workspace directory structure"
|
||||||
- name: Setup .NET
|
pwd
|
||||||
uses: actions/setup-dotnet@v4
|
echo "Root files:"
|
||||||
with:
|
ls -la
|
||||||
dotnet-version: '8.0.x' # ou sua versão
|
echo "YTExtractor folder contents:"
|
||||||
|
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: dotnet restore
|
run: |
|
||||||
|
echo "Navigating to YTExtractor directory and restoring..."
|
||||||
|
cd YTExtractor
|
||||||
|
ls -la
|
||||||
|
dotnet restore
|
||||||
|
|
||||||
- name: Build application
|
- name: Build application
|
||||||
run: dotnet build --configuration Release --no-restore
|
run: |
|
||||||
|
echo "Building from YTExtractor directory..."
|
||||||
|
cd YTExtractor
|
||||||
|
dotnet build --configuration Release --no-restore
|
||||||
|
|
||||||
- name: Run tests (opcional)
|
- name: Run tests (opcional)
|
||||||
run: dotnet test --no-build --verbosity normal
|
run: |
|
||||||
|
echo "Running tests from YTExtractor directory..."
|
||||||
|
cd YTExtractor
|
||||||
|
dotnet test --no-build --verbosity normal || true
|
||||||
|
|
||||||
- name: Publish application
|
- name: Publish application
|
||||||
run: dotnet publish --configuration Release --output ./publish
|
run: |
|
||||||
|
echo "Publishing from YTExtractor directory..."
|
||||||
|
cd YTExtractor
|
||||||
|
dotnet publish --configuration Release --output ../publish
|
||||||
|
|
||||||
- name: Build Docker image
|
- name: Build Docker image
|
||||||
run: |
|
run: |
|
||||||
docker build -t ytextractor:${{ github.sha }} .
|
echo "Current directory: $(pwd)"
|
||||||
docker tag ytextractor:${{ github.sha }} registry.redecarneir.us/ytextractor:latest
|
echo "Files in current directory:"
|
||||||
docker tag ytextractor:${{ github.sha }} registry.redecarneir.us/ytextractor:${{ github.sha }}
|
ls -la
|
||||||
|
|
||||||
|
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:${{ github.sha }}
|
docker push registry.redecarneir.us/ytextractor:$COMMIT_SHA
|
||||||
|
|
||||||
- name: Deploy to remote VPS
|
- name: Deploy to remote VPS
|
||||||
run: |
|
run: |
|
||||||
@ -51,17 +95,24 @@ 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:8080 \
|
-p 5000:80 \
|
||||||
-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