62 lines
1.7 KiB
YAML
62 lines
1.7 KiB
YAML
name: Laravel CI-CD (Gitea)
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
|
|
jobs:
|
|
test:
|
|
name: "Tests Unitaires"
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Run Tests
|
|
uses: docker://laravelsail/php84-composer:latest
|
|
env:
|
|
APP_ENV: testing
|
|
APP_KEY: base64:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
|
|
DB_CONNECTION: sqlite
|
|
DB_DATABASE: ":memory:"
|
|
with:
|
|
args: |
|
|
bash -c "apt-get update && apt-get install -y libicu-dev && \
|
|
docker-php-ext-configure intl && docker-php-ext-install intl && \
|
|
composer install --no-interaction && \
|
|
php artisan test"
|
|
|
|
build:
|
|
name: "Build & Push Docker"
|
|
needs: test
|
|
if: github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Login to Gitea Registry
|
|
uses: actions/docker/login@v2
|
|
with:
|
|
registry: ${{ github.server_url }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.TOKEN_GITEA }}
|
|
|
|
- name: Build and Push
|
|
run: |
|
|
# On utilise l'image du serveur Gitea
|
|
REGISTRY=$(echo "${{ github.server_url }}" | sed -e 's|https://||')
|
|
IMAGE="$REGISTRY/${{ github.repository }}:latest"
|
|
docker build -t "$IMAGE" .
|
|
docker push "$IMAGE"
|
|
|
|
deploy:
|
|
name: "Déploiement Simplifié"
|
|
needs: build
|
|
if: github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Trigger Portainer Webhook
|
|
run: |
|
|
curl -X POST "${{ secrets.PORTAINER_WEBHOOK_URL }}"
|