-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
52 lines (49 loc) · 1.39 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: 'Docker image'
description: 'Builds and publishes a Docker image to Amazon ECR.'
inputs:
aws-access-key-id:
description: >
AWS Access Key ID.
required: true
aws-secret-access-key:
description: >
AWS Secret Access Key.
required: true
aws-region:
description: >
AWS Region.
default: eu-west-3
required: false
repository:
description: >
AWS ECR registry repository.
required: true
tag:
description: >
Image tag.
required: true
runs:
using: 'composite'
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ inputs.aws-access-key-id }}
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
aws-region: ${{ inputs.aws-region }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ inputs.repository }}
IMAGE_TAG: ${{ inputs.tag }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
shell: bash
- name: Log out of Amazon ECR
if: always()
run: docker logout ${{ steps.login-ecr.outputs.registry }}
shell: bash