-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
46 lines (45 loc) · 1.47 KB
/
action.yaml
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
name: Image
description: Build and publish image to ECR
inputs:
aws-region:
description: AWS region
required: true
default: 'eu-west-1'
environment:
description: Target CDK environment
required: true
role:
description: Assume role
required: true
service-name:
description: Service name
required: true
default: admin
repository:
description: ECR respository name
required: true
default: techloop/admin
runs:
using: composite
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
ECR_REPOSITORY: ${{ inputs.repository }}
AWS_REGION: ${{ inputs.aws-region }}
ENVIRONMENT: ${{ inputs.environment }}
shell: bash
run: |
aws ecr get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin $ECR_REGISTRY
docker build . -f Dockerfile -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:$ENVIRONMENT
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$ENVIRONMENT
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT