25 lines
849 B
YAML
25 lines
849 B
YAML
|
name: Build and push Docker container
|
||
|
on: [push]
|
||
|
|
||
|
jobs:
|
||
|
build:
|
||
|
runs-on: metal-docker
|
||
|
steps:
|
||
|
- name: Check out repository code
|
||
|
uses: actions/checkout@v3
|
||
|
- run: |
|
||
|
ls -la
|
||
|
if [ x"$GITHUB_REF_NAME" = xmain ];then
|
||
|
NODE_RED_VERSION=latest
|
||
|
else
|
||
|
NODE_RED_VERSION=$GITHUB_REF_NAME
|
||
|
fi
|
||
|
docker build --build-arg NODE_RED_VERSION="$NODE_RED_VERSION" --progress plain --iidfile iid.txt .
|
||
|
stringprefix() { [ ${#1} -le $2 ] && echo $1 && return 0 || stringprefix "${1%?}" $2 ; }
|
||
|
SHORTSHA="$(stringprefix "$GITHUB_SHA" 8)"
|
||
|
for TAG in "$SHORTSHA" "$GITHUB_REF_NAME";do
|
||
|
docker tag "`cat iid.txt`" "$DOCKER_REGISTRY/$GITHUB_REPOSITORY:$TAG"
|
||
|
docker push "$DOCKER_REGISTRY/$GITHUB_REPOSITORY:$TAG"
|
||
|
done
|
||
|
|