forked from pahud/ecr-public-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·36 lines (27 loc) · 954 Bytes
/
entrypoint.sh
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
#!/bin/sh -l
CONTEXT=${INPUT_CONTEXT-.}
[ -z $CONTEXT ] && CONTEXT='.'
DOCKERFILE=${INPUT_DOCKERFILE-Dockerfile}
[ -z $DOCKERFILE ] && DOCKERFILE='Dockerfile'
echo $INPUT_CREATE_REPO
CREATE_REPO=${INPUT_CREATE_REPO-false}
[ -z $CREATE_REPO ] && CREATE_REPO='false'
echo $CREATE_REPO
echo "check repo exist or not"
REPO=$CREATE_REPO
if [ $CREATE_REPO != false ]; then
aws ecr-public describe-repositories --region us-east-1 --repository-names $REPO || aws ecr-public create-repository --repository-name $REPO
fi
echo "INPUT_TAGS=${INPUT_TAGS}"
TAGS=$(echo $INPUT_TAGS | tr "\n" " ")
echo "found TAGS=$TAGS"
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
echo "docker build -t tmp -f ${DOCKERFILE} ${CONTEXT}"
docker build -t tmp -f ${DOCKERFILE} ${CONTEXT}
for t in ${TAGS}
do
echo "docker tag tmp $t"
docker tag tmp $t
echo "docker push $t"
docker push $t
done