|
1 |
| -name: Reusable build and deploy to ecr workflow |
| 1 | +name: Reusable build and deploy to ECR workflow |
2 | 2 |
|
3 | 3 | on:
|
4 | 4 | workflow_call:
|
5 | 5 | inputs:
|
6 |
| - aws-region: |
7 |
| - required: true |
8 |
| - type: string |
9 |
| - ecr-repo-name: |
10 |
| - required: true |
11 |
| - type: string |
12 |
| - image-tag: |
13 |
| - required: true |
14 |
| - type: string |
| 6 | + aws-region: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + ecr-repo-name: |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + image-tag: |
| 13 | + required: true |
| 14 | + type: string |
15 | 15 | secrets:
|
16 | 16 | AWS_ACCESS_KEY_ID:
|
17 | 17 | required: true
|
18 | 18 | AWS_SECRET_ACCESS_KEY:
|
19 | 19 | required: true
|
20 | 20 |
|
21 |
| - |
22 | 21 | jobs:
|
23 | 22 | build-images-and-push-to-ecr:
|
24 | 23 | runs-on: ubuntu-latest
|
25 | 24 | steps:
|
26 |
| - - name: Checkout |
| 25 | + - name: Checkout Repository |
27 | 26 | uses: actions/checkout@v4
|
28 |
| - - name: Configure AWS credentials |
| 27 | + |
| 28 | + - name: Configure AWS Credentials |
29 | 29 | uses: aws-actions/configure-aws-credentials@v1
|
30 | 30 | with:
|
31 | 31 | aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
32 | 32 | aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
33 |
| - aws-region: ${{ input.aws-region }} |
34 |
| - env: |
35 |
| - ECR_REPOSITORY: ${{ input.ecr-repo-name }} |
36 |
| - IMAGE_TAG: ${{ input.image-tag }} |
37 |
| - |
| 33 | + aws-region: ${{ inputs.aws-region }} |
| 34 | + |
38 | 35 | - name: Login to Amazon ECR
|
39 | 36 | id: login-ecr
|
40 | 37 | uses: aws-actions/amazon-ecr-login@v1
|
41 | 38 |
|
42 |
| - - name: Build, tag, and push image to Amazon ECR |
| 39 | + - name: Build, Tag, and Push Image to Amazon ECR |
43 | 40 | id: build-image
|
44 | 41 | working-directory: src/validation_lambda
|
45 | 42 | env:
|
46 | 43 | ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
| 44 | + ECR_REPOSITORY: ${{ inputs.ecr-repo-name }} |
| 45 | + IMAGE_TAG: ${{ inputs.image-tag }} |
47 | 46 | run: |
|
48 |
| - # Build a docker container and |
49 |
| - # push it to ECR to be used in lambda. |
| 47 | + echo "Building Docker image..." |
50 | 48 | docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
|
| 49 | + echo "Pushing image to ECR..." |
51 | 50 | docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
|
52 |
| - echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" |
| 51 | + echo "Image successfully pushed: $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" |
0 commit comments