GuilhermeStracini/POC-GHActions-CI-PHPLaravel

View on GitHub
.github/workflows/deploy.yml

Summary

Maintainability
Test Coverage
name: Deploy via ftp
on:
  push:
    branches: [main]
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  deploy:
    name: Deploy to FTP
    runs-on: ubuntu-latest
    outputs:
      semVer: ${{ steps.gitversion.outputs.semVer }}

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Install GitVersion
        uses: gittools/actions/gitversion/setup@v2
        with:
          versionSpec: "5.x"

      - name: Determine Version
        id: gitversion
        uses: gittools/actions/gitversion/execute@v2
        with:
          useConfigFile: true

      - name: Setup PHP runtime
        uses: shivammathur/setup-php@v2
        with:
          coverage: "none"

      - name: Cache Composer dependencies
        uses: actions/cache@v4
        with:
          path: /tmp/composer-cache
          key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}

      - name: Install dependencies
        uses: "php-actions/composer@v6"
        with:
          dev: yes
          progress: yes

      - name: Set up environment
        run: |
          php -r "file_exists('.env') || copy('.env.example', '.env');"
          php artisan key:generate

      - name: PHPUnit Tests
        uses: php-actions/phpunit@v3
        with:
          version: 11
          php_version: 8.3
          php_extensions: xdebug
          coverage_cobertura: coverage.xml
          configuration: phpunit.xml
          test_suffix: Test.php
          args: --coverage-filter tests
        env:
          XDEBUG_MODE: coverage

      # - name: Upload service
      #   uses: sebastianpopp/ftp-action@releases/v2
      #   with:
      #     host: test.rebex.net
      #     user: demo
      #     password: password