Skip to content
This repository was archived by the owner on Apr 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
.gitignore
README.md
Dockerfile
.dockerignore
129 changes: 129 additions & 0 deletions .github/workflows/ci-cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: CI/CD Pipeline

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Test Backend
working-directory: ./app/back
continue-on-error: true
run: |
go mod tidy
go mod download
go test -v ./...

- name: Test CDN
working-directory: ./app/cdn
continue-on-error: true
run: |
go mod tidy
go mod download
go test -v ./...

build:
needs: test
if: always()
runs-on: ubuntu-latest
strategy:
matrix:
component: [back, front, cdn]
steps:
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push ${{ matrix.component }}
uses: docker/build-push-action@v5
with:
context: .
file: docker/${{ matrix.component }}/Dockerfile
push: ${{ github.ref == 'refs/heads/main' }}
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/goofy-${{ matrix.component }}:latest
${{ secrets.DOCKERHUB_USERNAME }}/goofy-${{ matrix.component }}:${{ github.sha }}
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/goofy-${{ matrix.component }}:buildcache
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/goofy-${{ matrix.component }}:buildcache,mode=max

deploy:
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-3

- name: Update kube config
run: aws eks update-kubeconfig --name hetic-groupe-3

- name: Create or update Kubernetes secrets
run: |
# Créer ou mettre à jour les secrets de l'application
kubectl create secret generic app-secrets \
--namespace goofy-cdn \
--from-literal=mongodb-uri="${{ secrets.MONGODB_URI }}" \
--from-literal=jwt-secret="${{ secrets.JWT_SECRET }}" \
--dry-run=client -o yaml | kubectl apply -f -

# Créer ou mettre à jour les secrets du monitoring
kubectl create secret generic monitoring-secrets \
--namespace monitoring \
--from-literal=grafana-admin-password="${{ secrets.GRAFANA_ADMIN_PASSWORD }}" \
--dry-run=client -o yaml | kubectl apply -f -

- name: Deploy to Kubernetes
run: |
# Mise à jour des images dans les deployments
kubectl set image deployment/backend backend=\
${{ secrets.DOCKERHUB_USERNAME }}/goofy-back:${{ github.sha }} -n goofy-cdn
kubectl set image deployment/frontend frontend=\
${{ secrets.DOCKERHUB_USERNAME }}/goofy-front:${{ github.sha }} -n goofy-cdn
kubectl set image deployment/cdn cdn=\
${{ secrets.DOCKERHUB_USERNAME }}/goofy-cdn:${{ github.sha }} -n goofy-cdn

# Vérification du déploiement
kubectl rollout status deployment/backend -n goofy-cdn
kubectl rollout status deployment/frontend -n goofy-cdn
kubectl rollout status deployment/cdn -n goofy-cdn

# - name: Notify Slack on Success
# if: success()
# uses: rtCamp/action-slack-notify@v2
# env:
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# SLACK_MESSAGE: "Déploiement réussi sur production :rocket:"
# SLACK_COLOR: good

# - name: Notify Slack on Failure
# if: failure()
# uses: rtCamp/action-slack-notify@v2
# env:
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# SLACK_MESSAGE: ":x: Échec du déploiement sur production"
# SLACK_COLOR: danger
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.idea/
.windsurfrules

# Temporary files
**/**/tmp
tmp/
*.log
air.log

# Binary files
**/main

# Environment variables
.env
.env.localgit
uploads
Loading
Loading