Add Gitea CI/CD workflow and update compose to use registry image
This commit is contained in:
53
.gitea/workflows/build-and-deploy.yml
Normal file
53
.gitea/workflows/build-and-deploy.yml
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
name: build-and-deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
#───────────────── build & push ─────────────────
|
||||||
|
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+push amigos-app
|
||||||
|
run: |
|
||||||
|
docker build -t $REG/amigos-app:${{ github.sha }} -t $REG/amigos-app:latest .
|
||||||
|
docker push $REG/amigos-app:${{ github.sha }}
|
||||||
|
docker push $REG/amigos-app:latest
|
||||||
|
|
||||||
|
#───────────────── deploy ─────────────────
|
||||||
|
deploy:
|
||||||
|
needs: build
|
||||||
|
runs-on: docker
|
||||||
|
env:
|
||||||
|
REG: gitea.nucleoriofrio.com/nucleo000
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Login to registry
|
||||||
|
run: docker login gitea.nucleoriofrio.com -u nucleo000 -p 7bc7b2fcd283bd6a251bef3ede368b7f897c919d
|
||||||
|
|
||||||
|
- name: Info about MongoDB
|
||||||
|
run: |
|
||||||
|
echo "ℹ️ MongoDB will be deployed with default credentials"
|
||||||
|
echo " Database: testdb"
|
||||||
|
echo " Username: admin"
|
||||||
|
echo " Password: MongoPass2024!"
|
||||||
|
|
||||||
|
- name: Pull fresh images used in compose
|
||||||
|
run: docker compose pull
|
||||||
|
|
||||||
|
- name: Clean up stack
|
||||||
|
run: docker compose --project-name amigos-app down
|
||||||
|
|
||||||
|
- name: Update stack
|
||||||
|
run: docker compose --project-name amigos-app up -d --remove-orphans --wait
|
||||||
@@ -39,6 +39,15 @@ app.get('/api/amigos', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get('/api/vistiantes_hoy', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const amigos = await amigosCollection.find({}).toArray();
|
||||||
|
res.json(amigos);
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: error.message });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Add new amigo
|
// Add new amigo
|
||||||
app.post('/api/amigos', async (req, res) => {
|
app.post('/api/amigos', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ version: '3.8'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
amigos-app:
|
amigos-app:
|
||||||
build: .
|
image: gitea.nucleoriofrio.com/nucleo000/amigos-app:latest
|
||||||
container_name: amigos-app
|
container_name: amigos-app
|
||||||
ports:
|
ports:
|
||||||
- "3001:3001"
|
- "3001:3001"
|
||||||
|
|||||||
Reference in New Issue
Block a user