From 946fc72a68ce6dac40052f232aebb10c1625b2f5 Mon Sep 17 00:00:00 2001 From: Oluwatunmise-olat Date: Mon, 29 Jan 2024 10:41:48 +0100 Subject: [PATCH] chore: test script with test credentials --- .github/workflows/pre-deployment.yml | 51 ++++++++++++++++++++ src/modules/entrypoint/entrypoint.service.ts | 1 - 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pre-deployment.yml diff --git a/.github/workflows/pre-deployment.yml b/.github/workflows/pre-deployment.yml new file mode 100644 index 0000000..9c8fa9c --- /dev/null +++ b/.github/workflows/pre-deployment.yml @@ -0,0 +1,51 @@ +name: "Pre Deployment Script" + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build_app: + runs-on: ubuntu-latest + steps: + - name: Pull Repository + uses: actions/checkout@v2 + - name: Setup and Install Node.Js + uses: actions/setup-node@v3.4.1 + with: + node-version: "16.x" + cache: "yarn" + - name: Install Dependencies + run: yarn install --frozen-lockfile + - name: Build Application + run: yarn run app:build + + build_docker_image_and_push_to_ecr: + runs-on: ubuntu-latest + needs: build_app + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.REGION }} + + - name: Login to AWS ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build and Push Docker Image to Amazon ECR + run: | + docker build -t ${{ secrets.REGISTRY_URL }}/${{ secrets.REPOSITORY_NAME }}:latest . + docker push ${{ secrets.REGISTRY_URL }}/${{ secrets.REPOSITORY_NAME }}:latest + - name: Deploy to Lambda + run: | + aws lambda update-function-code --function-name ${{ vars.FUNCTION_NAME }} --image-uri ${{ secrets.REGISTRY_URL }}/${{ secrets.REPOSITORY_NAME }}:latest diff --git a/src/modules/entrypoint/entrypoint.service.ts b/src/modules/entrypoint/entrypoint.service.ts index 62f6343..0d696a4 100644 --- a/src/modules/entrypoint/entrypoint.service.ts +++ b/src/modules/entrypoint/entrypoint.service.ts @@ -9,7 +9,6 @@ import { AWSSqs } from "@shared/utils/aws/sqs.util"; import { YoutubeDL } from "@shared/utils/youtube-dl/youtube-dl.util"; // TODO:: Prod ses access -// Post deployment script to build app, push to Aws ecr on merge or push to master and deploy to lambda // Infra provisioning script (terraform) @injectable()