Skip to content

Serveur web de test #19

Serveur web de test

Serveur web de test #19

Workflow file for this run

name: CI/CD Pipeline on Dev
on:
push:
branches:
- dev
jobs:
build:
runs-on: ubuntu-latest
environment: Dev
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
# - name: Lint with flake8
# run: |
# pip install flake8
# flake8 .
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Create ECR repository if it does not exist
env:
ECR_REPOSITORY: lwitter-repo
run: |
aws ecr describe-repositories --repository-names $ECR_REPOSITORY || aws ecr create-repository --repository-name $ECR_REPOSITORY
- name: Build, tag, and push Docker image
env:
#ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com
ECR_REPOSITORY: lwitter-repo
#IMAGE_TAG: ${{ github.sha }}
IMAGE_TAG: latest
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Update ECS service
env:
CLUSTER_NAME: lwitter-dev-cluster
SERVICE_NAME: lwitter-dev-service
CONTAINER_NAME: lwitter-light-container
IMAGE_URL: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com/lwitter-repo:latest
run: |
aws ecs update-service --cluster $CLUSTER_NAME --service $SERVICE_NAME --force-new-deployment --region eu-west-3 --output json
# - name: Deploy to ECS (version differente)
# env:
# AWS_DEFAULT_REGION: eu-west-3
# ECS_CLUSTER_NAME: twitter-stage-cluster
# ECS_SERVICE_NAME: twitter-stage-service
# IMAGE_URI: ${{ steps.login-ecr.outputs.registry }}/twitter_light:latest
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# run: |
# aws ecs update-service --cluster $ECS_CLUSTER_NAME --service $ECS_SERVICE_NAME --force-new-deployment