# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Symfony

on:
  push:
    branches: [ "master" ]
  pull_request:
    branches: [ "master" ]

permissions:
  contents: write

jobs:
  symfony-tests:
    runs-on: ubuntu-latest
    steps:
    #  To automatically get bug fixes and new Php versions for shivammathur/setup-php,
    # change this to (see https://github.com/shivammathur/setup-php#bookmark-versioning):
    # uses: shivammathur/setup-php@v2
    - uses: shivammathur/setup-php@2cb9b829437ee246e9b3cac53555a39208ca6d28
      with:
        php-version: '8.2'
    - uses: actions/checkout@v4
    - name: Copy .env.test.local
      run: php -r "file_exists('.env.test.local') || copy('.env.test', '.env.test.local');"
    - name: Set the ENV to prod
      run: echo "APP_ENV=prod" >> .env.test.local
    - name: Cache Composer packages
      id: composer-cache
      uses: actions/cache@v3
      with:
        path: vendor
        key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
        restore-keys: |
          ${{ runner.os }}-php-
    - name: Install Dependencies
      run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
    - name: Create Database
      run: |
        mkdir -p data
        touch data/database.sqlite
    - name: Create a zip file of the project
      run: zip -r latest.zip config public src templates vendor .env composer.json
    - name: Create release
      uses: softprops/action-gh-release@v2
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        tag_name: latest
        files: |
          latest.zip
          MISE_A_JOUR.bat