diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml new file mode 100644 index 0000000..80273b3 --- /dev/null +++ b/.github/workflows/manual.yml @@ -0,0 +1,49 @@ +name: Deploy image to AWS ECR + +# Run this workflow every time a new tag is created +on: + create: + tags: + - .* +jobs: + ecr: + # Name the Job + name: build and deploy image to AWS ECR + # Set the type of machine to run on + runs-on: ubuntu-latest + + steps: + - 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: Check out code + uses: actions/checkout@v2 + - name: Set Tag Number + id: tag-number + run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} + - name: Check Tag Release + env: + RELEASE_VERSION: ${{ steps.tag-number.outputs.tag }} + run: | + echo $RELEASE_VERSION + echo ${{ steps.vars.outputs.tag }} + + - name: Build, tag, and push image to Amazon ECR + env: + ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }} + ECR_REPOSITORY: demo + IMAGE_TAG: ${{ steps.tag-number.outputs.tag }} + run: | + docker build -t demo . + docker tag demo:latest $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + +