CI/CD #56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: # Déclenchement manuel uniquement | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: false | |
| load: true | |
| tags: quartify:test | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Test Docker image | |
| run: | | |
| # Démarrer le conteneur en arrière-plan | |
| docker run -d --name quartify-test -p 3838:3838 quartify:test | |
| # Attendre que l'application démarre | |
| sleep 30 | |
| # Vérifier que Quarto est installé | |
| docker exec quartify-test quarto --version | |
| # Vérifier que le package R est installé | |
| docker exec quartify-test Rscript -e "if (!require('quartify')) stop('quartify not installed')" | |
| # Vérifier que l'application répond (optionnel) | |
| # curl -f http://localhost:3838/ || exit 1 | |
| # Arrêter et supprimer le conteneur | |
| docker stop quartify-test | |
| docker rm quartify-test | |
| - name: Login to Docker Hub | |
| if: github.event_name == 'workflow_dispatch' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push to Docker Hub | |
| if: github.event_name == 'workflow_dispatch' | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ${{ secrets.DOCKERHUB_USERNAME }}/quartify:latest | |
| ${{ secrets.DOCKERHUB_USERNAME }}/quartify:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |