feat; pipeline
This commit is contained in:
parent
9e85f28bf6
commit
aa1781bdfd
99
YTExtractor/.gitea/workflow/main.yml
Normal file
99
YTExtractor/.gitea/workflow/main.yml
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
name: CI/CD Pipeline para YTExtractor
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, 'release/*' ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main, 'release/*' ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup .NET
|
||||||
|
uses: actions/setup-dotnet@v3
|
||||||
|
with:
|
||||||
|
dotnet-version: '8.0.x'
|
||||||
|
|
||||||
|
- name: Restore dependencies
|
||||||
|
run: dotnet restore
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: dotnet build --no-restore
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: dotnet test --no-build --verbosity normal
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: false
|
||||||
|
load: true
|
||||||
|
tags: ytextractor:${{ github.sha }}
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
|
||||||
|
- name: Save Docker image
|
||||||
|
run: docker save ytextractor:${{ github.sha }} > ytextractor-image.tar
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: docker-image
|
||||||
|
path: ytextractor-image.tar
|
||||||
|
|
||||||
|
deploy-localACDC:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download artifact
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: docker-image
|
||||||
|
|
||||||
|
- name: Deploy to localACDC
|
||||||
|
run: |
|
||||||
|
echo "Implantando no servidor localACDC"
|
||||||
|
scp ytextractor-image.tar user@localACDC:/tmp/
|
||||||
|
ssh user@localACDC "docker load < /tmp/ytextractor-image.tar && \
|
||||||
|
docker stop ytextractor || true && \
|
||||||
|
docker rm ytextractor || true && \
|
||||||
|
docker run -d --name ytextractor -p 80:80 ytextractor:${{ github.sha }}"
|
||||||
|
|
||||||
|
deploy-pi2Zero:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
if: startsWith(github.ref, 'refs/heads/release/')
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download artifact
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: docker-image
|
||||||
|
|
||||||
|
- name: Deploy to pi2Zero (Orange Pi Zero)
|
||||||
|
run: |
|
||||||
|
echo "Implantando no Orange Pi Zero (recursos limitados)"
|
||||||
|
# Transfere a imagem para o servidor
|
||||||
|
scp ytextractor-image.tar user@pi2Zero:/tmp/
|
||||||
|
|
||||||
|
# Comandos específicos para o Orange Pi Zero (otimizados para baixa memória)
|
||||||
|
ssh user@pi2Zero "
|
||||||
|
# Limpar recursos não utilizados
|
||||||
|
docker system prune -f
|
||||||
|
|
||||||
|
# Parar e remover contêiner existente
|
||||||
|
docker stop ytextractor || true
|
||||||
|
docker rm ytextractor || true
|
||||||
|
|
||||||
|
# Carregar a nova imagem
|
||||||
|
docker load < /tmp/ytextractor-image.tar
|
||||||
|
|
||||||
|
# Iniciar o serviço com limites de memória
|
||||||
|
docker run -d --name ytextractor -p 80:80 --memory=300m --memory-swap=600m ytextractor:${{ github.sha }}
|
||||||
|
"
|
||||||
@ -16,4 +16,4 @@ RUN apt-get update && \
|
|||||||
which yt-dlp || (echo "yt-dlp not found" && exit 1)
|
which yt-dlp || (echo "yt-dlp not found" && exit 1)
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
ENTRYPOINT ["dotnet", "YTExtractor.dll"]
|
ENTRYPOINT ["dotnet", "YTExtractor.dll"]
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
@ -33,4 +33,8 @@
|
|||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include=".gitea\workflow\main.yml" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user