From 3d8eacab175649927b8c41e9f88d8933e1bed1e8 Mon Sep 17 00:00:00 2001 From: Restebance Date: Tue, 26 Nov 2024 10:26:30 -0500 Subject: [PATCH] [FEATURE] gen image for ecr --- .github/workflows/pipeline.yaml | 53 +++++++++++++++++++++++++++++++++ app.py | 8 +++++ 2 files changed, 61 insertions(+) create mode 100644 .github/workflows/pipeline.yaml diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/pipeline.yaml new file mode 100644 index 0000000..bf393f1 --- /dev/null +++ b/.github/workflows/pipeline.yaml @@ -0,0 +1,53 @@ +name: CdkPipeline +on: + push: + branches: + - "develop" + - "feature/ecs" +env: + SABIO_PIPELINE_USER_ACCESS_KEY_ID: ${{ secrets.SABIO_AWS_ACCESS_KEY_ID }} + SABIO_PIPELINE_USER_SECRET_ACCESS_KEY: ${{ secrets.SABIO_AWS_SECRET_ACCESS_KEY }} + SABIO_DEV_PIPELINE_EXECUTION_ROLE: arn:aws:iam::908027390749:role/AWSControlTowerExecution + SABIO_DEV_REGION: us-east-1 +jobs: + deploy: + if: github.ref == 'refs/heads/develop' + runs-on: ubuntu-latest + env: + APP_STAGE: dev + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: "3.11" + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version: "20" + - name: deploy to account id + run: | + echo "Deploy to account: ${{ github.event.inputs.target_account_id}}" + - name: Assume the testing pipeline user role + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ env.SABIO_PIPELINE_USER_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ env.SABIO_PIPELINE_USER_SECRET_ACCESS_KEY }} + aws-region: ${{ env.SABIO_DEV_REGION }} + role-to-assume: ${{ env.SABIO_DEV_PIPELINE_EXECUTION_ROLE }} + role-session-name: dev-ecs-deployment + role-duration-seconds: 3600 + role-skip-session-tagging: true + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: sabiocx/multiagent + IMAGE_TAG: ${{ github.sha }} + run: | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT \ No newline at end of file diff --git a/app.py b/app.py index e489548..bec0968 100644 --- a/app.py +++ b/app.py @@ -12,6 +12,14 @@ supervised_workflow = SupervisorWorkflow() supervised_chain = supervised_workflow.gen_chain() +@app.get("/") +async def default(): + return { + "data": { + "msg": "success" + } + } + # TODO manage request body class SupervisorData(BaseModel): message: str