diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..a0e03b3 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,42 @@ +name: Build and Deploy + +on: + push: + branches: [main] + workflow_dispatch: + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + container: + image: openjdk:21 + options: -v /var/run/docker.sock:/var/run/docker.sock + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Maven cache + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: maven-${{ hashFiles('pom.xml') }} + restore-keys: maven- + + - name: Build with Maven + run: mvn clean install -Dmaven.test.skip=true + + - name: Build Docker image + run: | + docker build -t auth-backend:latest -t auth-backend:${{ github.sha }} . + + - name: Deploy + run: | + docker stop auth-backend-container || true + docker rm auth-backend-container || true + docker run -d \ + --name auth-backend-container \ + --network nginx \ + -p 9001:9001 \ + --restart unless-stopped \ + auth-backend:latest