Skip to content
Snippets Groups Projects
Commit f705a36d authored by David Trattnig's avatar David Trattnig
Browse files

Initial CI script

parent b9f48022
No related branches found
No related tags found
No related merge requests found
Pipeline #1650 failed
image: node:12-alpine
stages:
- test
- release
.install_requirements: &install_requirements
- apt-get -qq update
- npm install
.release-rules: &release-rules
# rule to run job on a tag-reference which has the form number.number.number (semantic versioning)
# or number.number.number-text (semantic versioning + release-name)
# and where a Dockerfile exists
- if: $CI_COMMIT_TAG =~ /^\d+[.]\d+[.]\d+$/ || $CI_COMMIT_TAG =~ /^\d+[.]\d+[.]\d+[-]\S+$/
exists:
- Dockerfile
run test_build:
stage: test
before_script:
- *install_requirements
script:
- npm run build
docker-push:
# Use the official docker image.
image: docker:latest
stage: release
variables:
# the name of the image without version
AURA_IMAGE_NAME: "autoradio/player"
services:
- docker:dind
before_script:
# default repo is docker.io (aka docker hub)
- docker login -u "$DOCKER_ID" -p "$DOCKER_HUB_AUTH"
script:
# every commit on main branch should build image as unstable
# else it is from a tag (enforced by gitlab-ci rules)
# hint: tags are references independent of branches
- |
if [ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]
then docker build -t $AURA_IMAGE_NAME:unstable .
else docker build -t $AURA_IMAGE_NAME -t $AURA_IMAGE_NAME:$CI_COMMIT_TAG .
fi
# TODO: maybe isolate docker build and docker push
- docker push "$AURA_IMAGE_NAME" --all-tags
rules:
- *release-rules
# every commit on master/main branch should trigger a push to docker-hub as unstable without a release
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
exists:
- Dockerfile
release_job:
stage: release
needs:
- docker-push
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules: *release-rules
script:
- echo "this will be a release when there is a tag, but tags should be protected to be only createable by maintainers."
release:
name: 'Release $CI_COMMIT_TAG'
description: ./release-notes/$CI_COMMIT_TAG
tag_name: '$CI_COMMIT_TAG'
ref: '$CI_COMMIT_TAG'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment