2020-10-15 14:46:14 +00:00
|
|
|
image: "node:12-slim"
|
|
|
|
|
|
|
|
stages:
|
|
|
|
- test
|
2020-10-15 17:54:03 +00:00
|
|
|
- artifact
|
|
|
|
- release
|
2020-10-15 14:46:14 +00:00
|
|
|
|
|
|
|
before_script:
|
|
|
|
# Install dependencies
|
|
|
|
- apt-get update
|
|
|
|
- apt-get install -y git python3 build-essential libxtst6
|
|
|
|
|
|
|
|
# Prepare Chrome for puppeteer
|
|
|
|
- apt-get install -y wget gnupg
|
|
|
|
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
|
|
|
|
- sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
|
|
|
|
- apt-get update
|
|
|
|
- apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 --no-install-recommends
|
|
|
|
|
2021-02-16 13:12:49 +00:00
|
|
|
# Build Send, run npm tests
|
2020-10-15 14:46:14 +00:00
|
|
|
test:
|
|
|
|
stage: test
|
|
|
|
script:
|
|
|
|
- npm ci
|
|
|
|
- npm run lint
|
|
|
|
- npm test
|
2020-10-15 17:16:49 +00:00
|
|
|
|
2021-02-16 13:12:49 +00:00
|
|
|
# Build Docker image, export Docker image artifact
|
2020-10-15 17:54:03 +00:00
|
|
|
artifact-docker:
|
|
|
|
stage: artifact
|
2020-10-15 17:16:49 +00:00
|
|
|
image: docker:latest
|
2021-02-16 13:12:49 +00:00
|
|
|
needs: []
|
|
|
|
services:
|
|
|
|
- docker:dind
|
|
|
|
variables:
|
2021-02-16 13:24:58 +00:00
|
|
|
IMG_FILE: "send:git-$CI_COMMIT_SHORT_SHA.tar"
|
|
|
|
IMG_NAME: "send:git-$CI_COMMIT_SHORT_SHA"
|
2021-02-16 13:12:49 +00:00
|
|
|
before_script: []
|
|
|
|
script:
|
|
|
|
- docker build -t $IMG_NAME .
|
|
|
|
- docker image save -o $IMG_FILE $IMG_NAME
|
|
|
|
artifacts:
|
2021-02-16 13:24:58 +00:00
|
|
|
name: artifact-docker
|
2021-02-16 13:12:49 +00:00
|
|
|
paths:
|
|
|
|
- $IMG_FILE
|
|
|
|
expire_in: 1 week
|
|
|
|
|
|
|
|
# Release public Docker image for the master branch
|
|
|
|
release-docker-master:
|
|
|
|
stage: release
|
|
|
|
image: docker:latest
|
|
|
|
dependencies:
|
|
|
|
- artifact-docker
|
2020-10-15 17:16:49 +00:00
|
|
|
services:
|
|
|
|
- docker:dind
|
|
|
|
only:
|
|
|
|
- master
|
2021-02-16 13:12:49 +00:00
|
|
|
variables:
|
2021-02-16 13:24:58 +00:00
|
|
|
IMG_IMPORT_FILE: "send:git-$CI_COMMIT_SHORT_SHA.tar"
|
|
|
|
IMG_IMPORT_NAME: "send:git-$CI_COMMIT_SHORT_SHA"
|
|
|
|
IMG_NAME: "registry.gitlab.com/timvisee/send:master-$CI_COMMIT_SHORT_SHA"
|
2020-10-15 17:24:44 +00:00
|
|
|
before_script: []
|
2020-10-15 17:16:49 +00:00
|
|
|
script:
|
|
|
|
# Login in to registry
|
|
|
|
- 'docker login registry.gitlab.com -u $DOCKER_USER -p $DOCKER_PASS'
|
|
|
|
|
2021-02-16 13:12:49 +00:00
|
|
|
# Load existing, retag for new image images
|
|
|
|
- docker image load -i $IMG_IMPORT_FILE
|
|
|
|
- docker tag $IMG_IMPORT_NAME $IMG_NAME
|
|
|
|
|
|
|
|
# Publish tagged image
|
2020-10-15 17:16:49 +00:00
|
|
|
- docker push $IMG_NAME
|
2020-10-15 17:54:03 +00:00
|
|
|
|
2021-02-16 13:12:49 +00:00
|
|
|
- 'echo "Docker image artifact published, available as:" && echo " docker pull $IMG_NAME"'
|
|
|
|
|
|
|
|
# Release public Docker image for a version tag
|
2020-10-15 17:54:03 +00:00
|
|
|
release-docker:
|
|
|
|
stage: release
|
|
|
|
image: docker:latest
|
2021-02-16 13:12:49 +00:00
|
|
|
dependencies:
|
|
|
|
- artifact-docker
|
2020-10-15 17:54:03 +00:00
|
|
|
services:
|
|
|
|
- docker:dind
|
|
|
|
only:
|
|
|
|
- /^v(\d+\.)*\d+$/
|
2021-02-16 13:12:49 +00:00
|
|
|
variables:
|
2021-02-16 13:24:58 +00:00
|
|
|
IMG_IMPORT_FILE: "send:git-$CI_COMMIT_SHORT_SHA.tar"
|
|
|
|
IMG_IMPORT_NAME: "send:git-$CI_COMMIT_SHORT_SHA"
|
2021-02-16 13:12:49 +00:00
|
|
|
IMG_NAME: "registry.gitlab.com/timvisee/send:$CI_COMMIT_REF_NAME"
|
|
|
|
IMG_NAME_LATEST: "registry.gitlab.com/timvisee/send:latest"
|
2020-10-15 17:54:03 +00:00
|
|
|
before_script: []
|
|
|
|
script:
|
|
|
|
# Login in to registry
|
|
|
|
- 'docker login registry.gitlab.com -u $DOCKER_USER -p $DOCKER_PASS'
|
|
|
|
|
2021-02-16 13:12:49 +00:00
|
|
|
# Load existing, retag for new image images
|
|
|
|
- docker image load -i $IMG_IMPORT_FILE
|
|
|
|
- docker tag $IMG_IMPORT_NAME $IMG_NAME
|
|
|
|
- docker tag $IMG_IMPORT_NAME $IMG_NAME_LATEST
|
|
|
|
|
|
|
|
# Publish tagged image
|
2020-10-15 17:54:03 +00:00
|
|
|
- docker push $IMG_NAME
|
|
|
|
- docker push $IMG_NAME_LATEST
|
2021-02-16 13:12:49 +00:00
|
|
|
|
|
|
|
- 'echo "Docker image artifact published, available as:" && echo " docker pull $IMG_NAME_LATEST" && echo " docker pull $IMG_NAME"'
|