feat: ci/cd
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- develop
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
jobs:
|
||||
test:
|
||||
name: 🧪 Tests Laravel
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DB_CONNECTION: sqlite
|
||||
DB_DATABASE: database/database.sqlite
|
||||
steps:
|
||||
- name: 📥 Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: 🐘 Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.4'
|
||||
extensions: bcmath,ctype,curl,dom,fileinfo,intl,mbstring,openssl,pdo,tokenizer,xml,zip
|
||||
coverage: none
|
||||
|
||||
- name: Cache Composer
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.composer/cache
|
||||
key: composer-cache
|
||||
|
||||
- name: Install Composer dependencies
|
||||
run: |
|
||||
composer install \
|
||||
--no-interaction \
|
||||
--prefer-dist \
|
||||
--no-progress
|
||||
|
||||
- name: ⚙️ Prepare Laravel
|
||||
run: |
|
||||
cp .env.example .env
|
||||
php artisan key:generate
|
||||
touch database/database.sqlite
|
||||
php artisan migrate --force
|
||||
|
||||
|
||||
- name: 🧪 Run PHPUnit
|
||||
run: |
|
||||
php artisan test
|
||||
|
||||
|
||||
|
||||
docker:
|
||||
name: 🐳 Build & Push Image
|
||||
needs: test
|
||||
if: ${{ github.ref == 'refs/heads/main' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 📥 Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 🔐 Login Registry Gitea
|
||||
run: |
|
||||
docker login git.leonmorival.xyz \
|
||||
-u "${{ secrets.REGISTRY_USER }}" \
|
||||
-p "${{ secrets.REGISTRY_PASSWORD }}"
|
||||
|
||||
- name: 🏗️ Build image
|
||||
run: |
|
||||
docker build \
|
||||
-t git.leonmorival.xyz/leonm/daily-meal-api:latest \
|
||||
-t git.leonmorival.xyz/leonm/daily-meal-api:${{ github.sha }} \
|
||||
.
|
||||
|
||||
- name: 📤 Push image
|
||||
run: |
|
||||
docker push git.leonmorival.xyz/leonm/daily-meal-api:latest
|
||||
docker push git.leonmorival.xyz/leonm/daily-meal-api:${{ github.sha }}
|
||||
Reference in New Issue
Block a user