Create laravel1.yml #2
This file contains 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: Laravel | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
laravel-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: shivammathur/setup-php@v2 # Updated action version for potential improvements and security updates | |
with: | |
php-version: '8.2' | |
extensions: mysql # Explicitly install the MySQL extension | |
- uses: actions/checkout@v4 | |
- name: Copy .env | |
run: php -r "file_exists('.env') || copy('.env.example', '.env');" | |
- name: Install Dependencies | |
run: composer install --no-interaction --no-dev # Removed -q, --no-ansi, --no-progress, --prefer-dist for better debugging. --no-dev is important | |
- name: Generate Application Key | |
run: php artisan key:generate --force # Added --force to avoid prompts in CI | |
- name: Set Directory Permissions | |
run: chmod -R 777 storage bootstrap/cache | |
- name: Create and Migrate Database (MySQL) | |
env: | |
DB_CONNECTION: mysql | |
DB_HOST: 127.0.0.1 # Or your MySQL host | |
DB_PORT: 3306 # Or your MySQL port | |
DB_DATABASE: tks_edu_lynk # Replace with your DB name | |
DB_USERNAME: root # Replace with your DB user | |
DB_PASSWORD: "" # Replace with your DB password or use secrets | |
run: | | |
# Start MySQL service (if not already running) - Adjust if needed based on your CI environment | |
sudo systemctl start mysql # or mysqld --initialize-insecure --user=mysql if you are initializing it. | |
mysql -e "CREATE DATABASE IF NOT EXISTS ${DB_DATABASE};" -u ${DB_USERNAME} -p${DB_PASSWORD} | |
php artisan migrate --seed # Added --seed if you have seeders and needs to run them. | |
- name: Run Tests | |
env: | |
DB_CONNECTION: mysql | |
DB_HOST: 127.0.0.1 # Or your MySQL host | |
DB_PORT: 3306 # Or your MySQL port | |
DB_DATABASE: tks_edu_lynk # Replace with your DB name | |
DB_USERNAME: root # Replace with your DB user | |
DB_PASSWORD: "" # Replace with your DB password or use secrets | |
run: php artisan test |