Skip to content

Commit

Permalink
feaT: add default tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Santos committed Jan 12, 2024
1 parent e8ecd8f commit e4f7a76
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ This action builds, tags, and pushes a Docker image to AWS ECR.

## Environment Variables

| Name | Description |
|------------------------|---------------------------------------|
| AWS_ACCESS_KEY_ID | AWS Access Key ID |
| AWS_SECRET_ACCESS_KEY | AWS Secret Access Key |
| AWS_ECR_REGION | AWS ECR Region |
| IMAGE_REPOSITORY_URL | AWS ECR Image Repository URL |
| IMAGE_TAG | Docker Image Tag (default: random hash) |
| PATH_DOCKERFILE | Dockerfile Path (default: ./Dockerfile) |
| Name | Description |
|------------------------|--------------------------------------------------|
| AWS_ACCESS_KEY_ID | AWS Access Key ID |
| AWS_SECRET_ACCESS_KEY | AWS Secret Access Key |
| AWS_ECR_REGION | AWS ECR Region |
| IMAGE_REPOSITORY_URL | AWS ECR Image Repository URL |
| IMAGE_TAG | Docker Image Tag (default: random hash) |
| IMAGE_TAG_DEFAULT | Docker Image Tag Default (default: latest) |
| PATH_DOCKERFILE | Dockerfile Path (default: ./Dockerfile) |

## Example Usage

Expand Down
12 changes: 10 additions & 2 deletions src/push
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ if [ -z "${IMAGE_REPOSITORY_URL}" ]; then
fi

IMAGE_TAG="${IMAGE_TAG:-$(openssl rand -hex 3)}"
IMAGE_TAG_DEFAULT="${IMAGE_TAG_DEFAULT:-latest}"
DOCKER_IMAGE=$IMAGE_REPOSITORY_URL:$IMAGE_TAG
DOCKER_IMAGE_DEFAULT=$IMAGE_REPOSITORY_URL:$IMAGE_TAG_DEFAULT
PATH_DOCKERFILE="${PATH_DOCKERFILE:-/}"
AWS_ECR_CONTAINER_REGISTRY_URL=$(echo $IMAGE_REPOSITORY_URL | cut -d'/' -f1)

Expand All @@ -47,16 +49,22 @@ then
fi

log_info "Building docker image"
if ! docker build --pull -t $DOCKER_IMAGE .${PATH_DOCKERFILE}
if ! docker build --pull -t $DOCKER_IMAGE -t $DOCKER_IMAGE_DEFAULT .${PATH_DOCKERFILE}
then
throw "Error on build docker image"
fi

log_info "Pushing docker image"
log_info "Pushing docker image with tag $IMAGE_TAG"
if ! docker push $DOCKER_IMAGE
then
throw "Error on push docker image"
fi

log_info "Pushing docker image with tag $IMAGE_TAG_DEFAULT"
if ! docker push $DOCKER_IMAGE_DEFAULT
then
throw "Error on push docker image"
fi

log_success "Docker image pushed"
echo $DOCKER_IMAGE

0 comments on commit e4f7a76

Please sign in to comment.