Some checks failed
Dotnet build and test / build (pull_request) Failing after 11s
72 lines
2.1 KiB
YAML
72 lines
2.1 KiB
YAML
name: Build and Push Yavsc Production Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
production-deploy:
|
|
runs-on: ubuntu-26.04
|
|
services:
|
|
postgres:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: postgres
|
|
ports:
|
|
- 5432:5432
|
|
options: >-
|
|
--health-cmd="pg_isready -U postgres -d postgres"
|
|
--health-interval=10s
|
|
--health-timeout=5s
|
|
--health-retries=5
|
|
steps:
|
|
# 1. Récupération du code
|
|
- name: Check out the repo
|
|
uses: actions/checkout@v7
|
|
|
|
# 2. Configuration du moteur de Buildx pour les builds multi-plateformes
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v4
|
|
|
|
# 3. Connexion sécurisée à Docker Hub
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v4
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
- name: Set up .NET
|
|
uses: actions/setup-dotnet@v3
|
|
with:
|
|
dotnet-version: 10.0.x
|
|
- name: Workloads restore
|
|
run: dotnet workload restore
|
|
- name: Test
|
|
env:
|
|
TEST_FAILED: ""
|
|
YAVSC_API_TEST_DB_PROVIDER: npgsql
|
|
YAVSC_API_TEST_NPGSQL_ADMIN_CONNECTION: Host=localhost;Port=5432;Database=postgres;Username=postgres;Password=postgres;Include Error Detail=true
|
|
run: make test || export TEST_FAILED=$?
|
|
- uses: actions/upload-artifact@v7
|
|
with:
|
|
name: my-artifact
|
|
path: test-reports/**/*
|
|
- name: Fail if tests failed
|
|
if: ${{ env.TEST_FAILED != '' && env.TEST_FAILED != '0' }}
|
|
run: exit $TEST_FAILED
|
|
|
|
# 4. Build et Push de l'image de production finale
|
|
- name: Build and push production image
|
|
uses: docker/build-push-action@v7
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile.backend
|
|
push: true
|
|
tags: |
|
|
pazof/yavsc:latest
|
|
pazof/yavsc:${{ github.sha }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|