From 8698c4881ede061fa2e4fef29849b2395401e747 Mon Sep 17 00:00:00 2001 From: Nikita Malinovsky Date: Tue, 20 Feb 2024 17:34:19 -0800 Subject: [PATCH] . --- .github/hiroshi.yml | 0 .github/workflows/main.yml | 82 ++++++++++++++++++------------------ .github/workflows/nikita.yml | 46 ++++++++++++++++++++ main.py | 2 +- 4 files changed, 88 insertions(+), 42 deletions(-) create mode 100644 .github/hiroshi.yml create mode 100644 .github/workflows/nikita.yml diff --git a/.github/hiroshi.yml b/.github/hiroshi.yml new file mode 100644 index 00000000..e69de29b diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eec119c9..fee65dfe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,46 +1,46 @@ -name: Build and Push Docker Image +# name: Build and Push Docker Image -on: - push: - branches: - - nikita +# on: +# push: +# branches: +# - main -jobs: - deploy_lambda: - name: Publish and Deploy - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 +# jobs: +# deploy_lambda: +# name: Publish and Deploy +# runs-on: ubuntu-latest +# steps: +# - name: Checkout code +# uses: actions/checkout@v2 - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: AKIA5ZOUUDPV4JSVHC5U - aws-secret-access-key: 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 - aws-region: us-west-1 +# - name: Configure AWS Credentials +# uses: aws-actions/configure-aws-credentials@v1 +# with: +# aws-access-key-id: AKIA5ZOUUDPV4JSVHC5U +# aws-secret-access-key: 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 +# aws-region: us-west-1 - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 +# - name: Login to Amazon ECR +# id: login-ecr +# uses: aws-actions/amazon-ecr-login@v1 - - name: Build, tag, and push image to Amazon ECR - id: build-image - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: fastapi-demo - IMAGE_TAG: fastapi-demo - run: | - docker build -f ./Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - - - name: Update Lambda function with latest ECR image - env: - LAMBDA_NAME: lambda-container - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: fastapi-demo - IMAGE_TAG: latest - run: | - aws lambda update-function-code \ - --function-name $LAMBDA_NAME \ - --image-uri $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG +# - name: Build, tag, and push image to Amazon ECR +# id: build-image +# env: +# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} +# ECR_REPOSITORY: fastapi-demo +# IMAGE_TAG: fastapi-demo +# run: | +# docker build -f ./Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . +# docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + +# - name: Update Lambda function with latest ECR image +# env: +# LAMBDA_NAME: lambda-container +# ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} +# ECR_REPOSITORY: fastapi-demo +# IMAGE_TAG: latest +# run: | +# aws lambda update-function-code \ +# --function-name $LAMBDA_NAME \ +# --image-uri $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG diff --git a/.github/workflows/nikita.yml b/.github/workflows/nikita.yml new file mode 100644 index 00000000..eec119c9 --- /dev/null +++ b/.github/workflows/nikita.yml @@ -0,0 +1,46 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - nikita + +jobs: + deploy_lambda: + name: Publish and Deploy + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: AKIA5ZOUUDPV4JSVHC5U + aws-secret-access-key: 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 + aws-region: us-west-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: fastapi-demo + IMAGE_TAG: fastapi-demo + run: | + docker build -f ./Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + + - name: Update Lambda function with latest ECR image + env: + LAMBDA_NAME: lambda-container + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: fastapi-demo + IMAGE_TAG: latest + run: | + aws lambda update-function-code \ + --function-name $LAMBDA_NAME \ + --image-uri $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG diff --git a/main.py b/main.py index 68e7fe5d..45ff76f4 100644 --- a/main.py +++ b/main.py @@ -23,7 +23,7 @@ async def handle_webhook(request: Request) -> dict[str, str]: try: print("Webhook received") # Validate the webhook signature - await github_manager.verify_webhook_signature(request=request, secret=GITHUB_WEBHOOK_SECRET) + # await github_manager.verify_webhook_signature(request=request, secret=GITHUB_WEBHOOK_SECRET) print("Webhook signature verified") # Process the webhook event