diff --git a/.github/workflows/deploy-on-aws.yml b/.github/workflows/deploy-on-aws.yml new file mode 100644 index 0000000..291115a --- /dev/null +++ b/.github/workflows/deploy-on-aws.yml @@ -0,0 +1,38 @@ +# This is a basic workflow to help you get started with Actions +name: Deploy to AWS ECR +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: [test/github-ecr-action] + pull_request: + branches: [test/github-ecr-action] +jobs: +build: +name: Build Image + runs-on: ubuntu-latest +# Steps represent a sequence of tasks that will be executed as part of the job + steps: + + - name: Check out code + uses: actions/checkout@v2 + - 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: ap-south-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 + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: code-problems + IMAGE_TAG: ${{ github.sha }} + run: | + # Build a docker container and push it to ECR + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . + echo "Pushing image to ECR..." + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..be8f56f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +# pull the official base image (Background o.s for container) +FROM python:3.9.7 + +# image comes with gpg 2.x but we need gpg 1.x +RUN apt-get update && \ + apt-get remove -y gnupg && \ + apt-get install -y gnupg1 +