41 lines
1.2 KiB
YAML
41 lines
1.2 KiB
YAML
name: Build and Deploy
|
|
on: [ push ]
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest # This refers to your self-hosted runner
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Login to Gitea Registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: git.ludops.com
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.CI_TOKEN }}
|
|
|
|
- name: Build and Push
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: ${{ vars.REGISTRY_IMAGE }}:latest
|
|
|
|
- name: Deploy to Server
|
|
env:
|
|
APP_NAME: ${{ vars.APP_NAME }}
|
|
REGISTRY_IMAGE: ${{ vars.REGISTRY_IMAGE }}
|
|
run: |
|
|
echo "${{ secrets.CI_TOKEN }}" | docker login git.ludops.com -u ${{ gitea.actor }} --password-stdin
|
|
docker compose -f docker-compose.prod.yml pull
|
|
docker run --rm --network infrastructure_infra-network \
|
|
-e DATABASE_URL=postgres://gitea:gitea@ludops-postgres:5432/${APP_NAME}_db \
|
|
${REGISTRY_IMAGE}:latest \
|
|
npx drizzle-kit push
|
|
docker compose -f docker-compose.prod.yml up -d
|
|
|