Files
2026-06-07 11:15:15 +02:00

82 lines
2.4 KiB
YAML

name: CI — Tests & Docker Build
on:
push:
branches:
- main
- 'feat/**'
pull_request:
jobs:
# test:
# name: Tests
# runs-on: ubuntu-latest
# services:
# postgres:
# image: postgres:16
# env:
# POSTGRES_DB: olhar_test
# POSTGRES_USER: olhar
# POSTGRES_PASSWORD: olhar
# ports:
# - 5432:5432
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# - name: Build image de test
# run: docker build -f Dockerfile.test -t olhar-api-test:ci .
# - name: Lancer les tests
# run: |
# docker run --rm \
# --network host \
# -e SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/olhar_test \
# -e SPRING_DATASOURCE_USERNAME=olhar \
# -e SPRING_DATASOURCE_PASSWORD=olhar \
# -e SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.postgresql.Driver \
# -e SECURITY_JWT_SECRET=test-secret-key-for-ci-testing-only-must-be-long-enough \
# olhar-api-test:ci \
# ./gradlew test --no-daemon
build-and-push:
name: Build & push image Docker
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Lire la version depuis build.gradle
id: version
run: echo "VERSION=$(grep '^version' build.gradle | awk -F"'" '{print $2}')" >> $GITHUB_OUTPUT
- name: Setup Buildx
uses: docker/setup-buildx-action@v3
- name: Login registry Gitea
uses: docker/login-action@v3
with:
registry: git.goutailler-olivier.com
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build & push image
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
push: true
tags: |
git.goutailler-olivier.com/gato/olhar-api:latest
git.goutailler-olivier.com/gato/olhar-api:${{ steps.version.outputs.VERSION }}
- name: Trigger déploiement Watchtower
run: |
wget -q --post-data='' \
--header="Authorization: Bearer ${{ secrets.WATCHTOWER_TOKEN }}" \
https://watchtower.goutailler-olivier.com/v1/update \
-O /dev/null