From 9ed696c1325e9f41420744568399cd6a54a7caa6 Mon Sep 17 00:00:00 2001 From: Zafor Abdullah <33929609+ZaforAbdullah@users.noreply.github.com> Date: Sun, 17 Nov 2024 23:01:29 +0800 Subject: [PATCH] Create main.yml --- .github/workflows/main.yml | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..43e818d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,51 @@ +name: GitHub Action + +on: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # Checkout the code + - name: Checkout code + uses: actions/checkout@v3 + + # Build Docker containers + - name: Build containers + run: docker compose -f docker-compose.dev.yml up -d --force-recreate --build + + # Application configuration + - name: Configure application + run: | + docker exec -i local /bin/bash -c 'composer update' + docker exec -i local /bin/bash -c '/usr/local/bin/php artisan config:clear' + docker exec -i local /bin/bash -c '/usr/local/bin/php artisan cache:clear' + docker exec -i local /bin/bash -c '/usr/local/bin/php artisan view:clear' + docker exec -i local /bin/bash -c '/usr/local/bin/php artisan DBConnection' + docker exec -i local /bin/bash -c '/usr/local/bin/php artisan migrate' + env: + # Add any environment variables here if needed + APP_ENV: testing + + # Run PHPUnit tests + - name: Run PHPUnit tests + run: docker exec -i local /bin/bash -c '/usr/local/bin/php artisan test' + + # Run Larastan static analysis + - name: Larastan analysis + run: docker exec -i local /bin/bash -c './vendor/bin/phpstan analyse --generate-baseline --memory-limit=2G' + + # Cleanup after the job + - name: Cleanup resources + run: | + docker compose -f docker-compose.dev.yml down + docker volume prune -f + docker image prune -f