Commit d3982610 authored by Vadym Gidulian's avatar Vadym Gidulian

Initial commit

parents
services:
- docker:dind
variables:
IMAGE_SNAPSHOT: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME-snapshot
IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
IMAGE_LATEST: $CI_REGISTRY_IMAGE:latest
stages:
- build
- test
- release
before_script:
- docker version
- docker info
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
build:
stage: build
script:
- docker build --pull -t $IMAGE_SNAPSHOT .
- docker push $IMAGE_SNAPSHOT
tags:
- dind
test:
stage: test
script:
- docker pull $IMAGE_SNAPSHOT
- docker run --rm --entrypoint='bash' $IMAGE_SNAPSHOT -c '[[ $(ls -A /usr/src/bolt) ]] && echo "Bolt is downloaded."'
tags:
- dind
release:
stage: release
script:
- docker pull $IMAGE_SNAPSHOT
- docker tag $IMAGE_SNAPSHOT $IMAGE
- docker push $IMAGE
tags:
- dind
except:
- master
release:latest:
stage: release
script:
- docker pull $IMAGE_SNAPSHOT
- docker tag $IMAGE_SNAPSHOT $IMAGE_LATEST
- docker push $IMAGE_LATEST
tags:
- dind
only:
- master
FROM alpine
MAINTAINER Vadym Gidulian <vadym.gidulian@gvia.group>
COPY entrypoint.sh /entrypoint.sh
COPY insert-hook.sh /usr/local/bin/insert-hook
COPY post-receive.sh /hooks/post-receive
RUN chmod +x /entrypoint.sh /usr/local/bin/insert-hook
VOLUME /gogs-repositories
ENTRYPOINT /entrypoint.sh
if [ -z "$INTERVAL" ]; then
echo 'Error: INTERVAL variable is not set!'
exit 1
fi
while /bin/true
do
find /gogs-repositories -mindepth 4 -maxdepth 4 -name 'post-receive' -exec insert-hook '{}' \;
sleep $INTERVAL
done
#!/bin/sh
if ! grep -q 'deploy script' "$1"; then
cat /hooks/post-receive >> "$1";
fi
# Start deploy script
while read oldrev newrev refname
do
branch=$(echo $refname | rev | cut -d / -f 1 | rev)
repo=$(pwd | rev | cut -d / -f 1,2 | cut -d . -f 2- | rev)
unset GIT_INDEX_FILE
mkdir -p "/projects/$repo/$branch"
git --work-tree="/projects/$repo/$branch" --git-dir=$(pwd) checkout -f $branch
done
# End deploy script
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment