Skip to content

feat(deploy): test deployment to kubernetes azure #10

feat(deploy): test deployment to kubernetes azure

feat(deploy): test deployment to kubernetes azure #10

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_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]
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@v1
with:
terraform_wrapper: false
- name: Terraform Init
run: terraform init
working-directory: ./deployment/terraform
- name: Terraform Apply
run: terraform apply -auto-approve
working-directory: ./deployment/terraform
- name: Setup kubectl
env:
AZURE_SUBSCRIPTION_ID: ${{ secrets.SUBSCRIPTION_ID }}
run: |
az aks get-credentials --resource-group ""aks-resource-group" --name "aks-cluster"
- name: Apply Kubernetes Deployment
working-directory: ./deployment/kubernetes
run: |
// remplacer la clé :latest par la version de l'image préfixé par :
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
kubectl apply -f webapp-deployment.yaml
kubectl apply -f webapp-service.yaml
kubectl apply -f api-deployment.yaml
kubectl apply -f api-service.yaml