59cc7cf161
Le montage de workspace ne fonctionne pas dans le runner Gitea (pwd ne pointe pas vers le checkout). On construit une image avec les sources embarquées et on lance les tests depuis cette image. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
70 lines
1.9 KiB
YAML
70 lines
1.9 KiB
YAML
name: CI — Tests & Docker Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- 'feat/**'
|
|
pull_request:
|
|
|
|
jobs:
|
|
test:
|
|
name: Tests
|
|
runs-on: ubuntu-latest
|
|
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 \
|
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
-e DOCKER_HOST=unix:///var/run/docker.sock \
|
|
-e TESTCONTAINERS_RYUK_DISABLED=true \
|
|
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
|