Commit a477f777 authored by AlmAck's avatar AlmAck

first gitlab-ci file

parent e42efd32
Pipeline #3 failed
# inspired by https://gist.github.com/ronalddddd/d402ec6f81647ab3db651136997a7a74
image: docker:latest
stages:
- build
- test
- release-image
variables:
CONTAINER_IMAGE_NAME: chakra-bootstrap
CONTAINER_REGISTRY_NAMESPACE: chakralinux
#CONTAINER_REGISTRY_DOMAIN: hub.docker.com
#CONTAINER_RELEASE_IMAGE: $CONTAINER_REGISTRY_DOMAIN/$CONTAINER_REGISTRY_NAMESPACE/$CONTAINER_IMAGE_NAME:latest
CONTAINER_RELEASE_IMAGE: $CONTAINER_REGISTRY_NAMESPACE/$CONTAINER_IMAGE_NAME:latest
before_script:
# Generate the test image tag from branch name, e.g.
# branch `chakralinux/chakra-bootstrap` becomes the docker image tag `chakra-bootstrap`
#- CONTAINER_TEST_IMAGE=$CONTAINER_REGISTRY_DOMAIN/$CONTAINER_REGISTRY_NAMESPACE/$CONTAINER_IMAGE_NAME:`echo $CI_BUILD_REF_NAME | sed -e 's/[\/|.]/-/g'`
- CONTAINER_TEST_IMAGE=$CONTAINER_REGISTRY_NAMESPACE/$CONTAINER_IMAGE_NAME:`echo $CI_BUILD_REF_NAME | sed -e 's/[\/|.]/-/g'`
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CONTAINER_REGISTRY_DOMAIN
build:
stage: build
only:
- schedules
before_script:
# we need a random generator enabled to speed up the pacman-key --populate generation
- apk add rng-tools
- service rngd start
#- echo HRNGDEVICE=/dev/urandom >> /etc/default/rng-tools && service rng-tools restart
script:
# generate the Chakra base bootstrap image
- ./bootstraps/scripts/build.sh
# builds and push the test image
- docker build $CONTAINER_TEST_IMAGE .
- docker login -u $DOCKER_REGISTRY_USERNAME -p $DOCKER_REGISTRY_PASSWORD
- docker push $CONTAINER_TEST_IMAGE
tags:
- docker
test:
stage: test
script:
# CI test script -- exit 0 for success or exit > 0 for failure, optionally output coverage info here
- { docker run --rm=true $CONTAINER_TEST_IMAGE echo "Success, $CONTAINER_TEST_IMAGE prepared." && exit 0; } || exit 1
release-image:
stage: release
script:
# finally, if this is the master branch, tag and push the image to `latest`
#- docker login -u $DOCKER_REGISTRY_USERNAME -p $DOCKER_REGISTRY_PASSWORD registry.gitlab.com
- docker login -u $DOCKER_REGISTRY_USERNAME -p $DOCKER_REGISTRY_PASSWORD
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE
only:
- master
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