71 lines
1.5 KiB
YAML
71 lines
1.5 KiB
YAML
name: Laravel CI-CD
|
|
|
|
on:
|
|
push:
|
|
branches: ["main"]
|
|
|
|
env:
|
|
REGISTRY: gitea.leonmorival.com
|
|
IMAGE_NAME: daily_meal/bemeal-api
|
|
|
|
jobs:
|
|
|
|
# =========================
|
|
# TESTS
|
|
# =========================
|
|
test:
|
|
name: Tests Unitaires
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup PHP container tests
|
|
run: |
|
|
docker run --rm \
|
|
-v $PWD:/app \
|
|
-w /app \
|
|
laravelsail/php84-composer:latest \
|
|
bash -c "composer install --no-interaction --ignore-platform-req=ext-intl && php artisan test"
|
|
|
|
|
|
# =========================
|
|
# BUILD & PUSH IMAGE
|
|
# =========================
|
|
build:
|
|
name: Build & Push Docker
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Login to Gitea Registry
|
|
run: |
|
|
echo "${{ secrets.TOKEN_GITEA }}" \
|
|
| docker login $REGISTRY \
|
|
-u "${{ github.actor }}" \
|
|
--password-stdin
|
|
|
|
- name: Build Docker image
|
|
run: |
|
|
IMAGE=$REGISTRY/$IMAGE_NAME:latest
|
|
docker build -t $IMAGE .
|
|
docker push $IMAGE
|
|
|
|
|
|
# =========================
|
|
# DEPLOY
|
|
# =========================
|
|
deploy:
|
|
name: Deploy via Portainer
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Trigger Portainer webhook
|
|
run: |
|
|
curl -X POST "${{ secrets.PORTAINER_WEBHOOK_URL }}"
|