Skip to content

start cleanning

start cleanning #104

Workflow file for this run

name: Python Continuous Integration
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
#env:
# PYTHON_VERSION: 3.11
# NODE_VERSION: 18
permissions:
id-token: write
contents: write
packages: write
jobs:
tags:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.tag.outputs.new_version }}
steps:
- uses: actions/checkout@v4
- name: Bump version and push tag
id: tag_version
if: github.ref == 'refs/heads/main'
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Add tag to output step for main branch
id: tag
run: |
if [ '${{ github.ref }}' = 'refs/heads/main' ]; then
echo "new_version=${{ steps.tag_version.outputs.new_version }}" >> $GITHUB_OUTPUT
else
echo "new_version=pr-${{ github.event.number }}-${{ github.run_number }}" >> $GITHUB_OUTPUT
fi
build_docker_api:
needs: [tags]
uses: ./.github/workflows/docker.yml
with:
image_name: "transcriptor-api"
image_version: ${{ needs.tags.outputs.new_version }}
image_build_args: ""
image_context: ./production/api
image_file: "./production/api/Dockerfile"
docker_registry: "ghcr.io"
docker_repository: "guillaume-chervet"
secrets:
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
build_docker_ia_worker:
needs: [ tags ]
uses: ./.github/workflows/docker.yml
with:
image_name: "transcriptor-ia-worker"
image_version: ${{ needs.tags.outputs.new_version }}
image_build_args: ""
image_context: ./production/ia-worker
image_file: "./production/ia-worker/Dockerfile"
docker_registry: "ghcr.io"
docker_repository: "guillaume-chervet"
secrets:
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
build_docker_webapp:
needs: [tags]
uses: ./.github/workflows/docker.yml
with:
image_name: "transcriptor-webapp"
image_version: ${{ needs.tags.outputs.new_version }}
image_build_args: ""
image_context: ./production/webapp
image_file: "./production/webapp/Dockerfile"
docker_registry: "ghcr.io"
docker_repository: "guillaume-chervet"
secrets:
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
deploy:
runs-on: ubuntu-latest
needs: [tags, build_docker_api, build_docker_webapp, build_docker_ia_worker]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false
- name: Terraform Init
working-directory: deploy/terraform
env:
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
run: terraform init
- name: Import Terraform Resource if Exists
working-directory: deploy/terraform
run: |
if az group show --name aks-resource-group --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }}; then
# Array des ressources à vérifier pour importation
resources=(
"azurerm_resource_group.aks_rg /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/aks-resource-group"
"azurerm_kubernetes_cluster.aks /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/aks-resource-group/providers/Microsoft.ContainerService/managedClusters/aks-cluster"
)
# Boucle pour chaque ressource dans la liste
for resource in "${resources[@]}"; do
# Sépare la ressource et son ID
res_type=$(echo $resource | awk '{print $1}')
res_id=$(echo $resource | awk '{print $2}')
# Vérifie si la ressource est déjà dans l'état Terraform
terraform state list -var="subscription_id=${{ secrets.AZURE_SUBSCRIPTION_ID }}" | grep "$res_type" || terraform import -var="subscription_id=${{ secrets.AZURE_SUBSCRIPTION_ID }}" $res_type $res_id
done
else
echo "Le groupe de ressources n'existe pas. Aucune importation effectuée."
fi
- name: Terraform Apply
run: terraform apply -auto-approve -var="subscription_id=${{ secrets.AZURE_SUBSCRIPTION_ID }}"
working-directory: deploy/terraform
- name: Setup kubectl
env:
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
run: |
az aks get-credentials --resource-group "aks-resource-group" --name "aks-cluster"
- name: Apply Kubernetes Deployment
working-directory: deploy/kubernetes
run: |
kubectl apply -f namespace.yaml
sed -i 's/:latest/:${{ needs.tags.outputs.new_version }}/g' api-deployment.yaml
sed -i 's/:latest/:${{ needs.tags.outputs.new_version }}/g' webapp-deployment.yaml
sed -i 's/:latest/:${{ needs.tags.outputs.new_version }}/g' ia-worker-deployment.yaml
kubectl apply -f webapp-deployment.yaml
kubectl apply -f webapp-service.yaml
kubectl apply -f webapp-ingress.yaml
kubectl apply -f api-deployment.yaml
kubectl apply -f api-service.yaml
kubectl apply -f ia-worker-deployment.yaml
kubectl apply -f ia-worker-service.yaml
kubectl apply -f slimfaas-deployment.yaml
kubectl apply -f slimfaas-ingress.yaml
kubectl apply -f redis-deployment.yaml
kubectl apply -f hpas.yaml