Restaurar carpeta .gitea para workflows

This commit is contained in:
2025-08-15 17:56:08 -06:00
parent 67d03e40ff
commit dceea1e7a5
2 changed files with 100 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
name: build-and-deploy
on:
push:
branches: [ main ]
jobs:
#───────────────── build & push imagen única ─────────────────
build:
runs-on: docker
env:
REG: gitea.nucleoriofrio.com/nucleo000
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: gitea.nucleoriofrio.com
username: nucleo000
password: 7bc7b2fcd283bd6a251bef3ede368b7f897c919d
- name: Build and push snatchgame
run: |
docker build -t $REG/snatchgame:${{ github.sha }} -t $REG/snatchgame:latest .
docker push $REG/snatchgame:${{ github.sha }}
docker push $REG/snatchgame:latest
#───────────────── deploy ─────────────────
deploy:
needs: build
runs-on: docker
env:
REG: gitea.nucleoriofrio.com/nucleo000
steps:
- name: Login to registry
run: docker login gitea.nucleoriofrio.com -u nucleo000 -p 7bc7b2fcd283bd6a251bef3ede368b7f897c919d
- name: Stop existing container
run: docker stop snatchgame || true
- name: Remove existing container
run: docker rm snatchgame || true
- name: Pull latest image
run: docker pull $REG/snatchgame:latest
- name: Run new container
run: |
docker run -d \
--name snatchgame \
--restart unless-stopped \
--network principal \
$REG/snatchgame:latest

View File

@@ -0,0 +1,47 @@
name: deploy-to-gcloud
on:
push:
branches: [ production ] # Solo desplegar cuando se pushee a rama production
jobs:
build-and-deploy:
runs-on: docker
env:
REG: gitea.nucleoriofrio.com/nucleo000
steps:
- uses: actions/checkout@v3
# Build y push imagen (igual que antes)
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: gitea.nucleoriofrio.com
username: nucleo000
password: 7bc7b2fcd283bd6a251bef3ede368b7f897c919d
- name: Build and push snatchgame
run: |
docker build -t $REG/snatchgame:latest .
docker push $REG/snatchgame:latest
# Deploy a Google Cloud VM
- name: Deploy to Google Cloud VM
run: |
# Instalar gcloud CLI si no está disponible
if ! command -v gcloud &> /dev/null; then
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
source /root/google-cloud-sdk/path.bash.inc
fi
# Configurar autenticación (necesitarás configurar service account)
# echo '${{ secrets.GCLOUD_SERVICE_KEY }}' | gcloud auth activate-service-account --key-file=-
# gcloud config set project tu-proyecto-gcloud
# Ejecutar deployment en la VM
gcloud compute ssh snatchgame-vm \
--zone=us-central1-a \
--command="sudo /opt/deploy-snatchgame.sh" \
|| echo "Deploy failed - VM might not exist yet"