case deliver #1
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: TheBackendProject | |
on: | |
push: | |
branches: ["master", "main"] | |
pull_request: | |
branches: ["master", "main"] | |
jobs: | |
lint: | |
name: Lint PHP files using Pint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 2 | |
- name: Pint | |
uses: aglipanci/[email protected] | |
with: | |
preset: laravel | |
- name: Commit changes | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: Fix code style | |
skip_fetch: true | |
backend: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Compose | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y docker-compose | |
working-directory: ./ | |
- name: Build and deploy Docker container | |
run: | | |
cd backend | |
docker build -t backend-app -f Dockerfile . | |
docker run -d -p 8000:8000 --name backend-app backend-app | |
working-directory: ./ | |
- name: Wait for the container to start | |
run: sleep 3 | |
- name: Create SQLite database | |
run: | | |
cd backend | |
touch database/database.sqlite | |
working-directory: ./ | |
- name: Test the application inside the Docker container | |
run: | | |
docker exec backend-app bash -c " | |
sed -i 's/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/g' .env.testing && | |
sed -i 's/DB_HOST=127.0.0.1/DB_HOST=:memory:/g' .env.testing && | |
php artisan key:generate && | |
php artisan migrate:fresh --seed --env=testing && | |
php artisan test | |
" | |
- name: Check the application url | |
run: curl http://localhost:8000 |