This repository has been archived by the owner on Oct 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy path.gitlab-ci.yml
73 lines (68 loc) · 3.32 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
image: docker:latest
stages:
- build
- deploy
variables:
DOCKER_DRIVER: overlay2
KOHAPATH: $CI_PROJECT_DIR
COMPOSE_CMD: docker-compose
DEBIAN_REPO_INCOMING: [email protected]:/var/www/static.deichman.no/repositories/koha/incoming/
DEBIAN_REPO_DIR: /var/www/static.deichman.no/repositories/koha
DOCKERHUB_USERNAME: deichman
before_script:
- apk update
- apk upgrade
- apk add git rsync openssh python python-dev py-pip build-base
- pip install docker-compose
build_debian_files:
stage: build
only:
- tags
script:
- source docker-compose/docker-compose.env
- if [[ "${CI_COMMIT_TAG}" != "${KOHA_RELEASE}" ]]; then echo "SKIPPED building debian files - uneven tags"; exit 0; fi
- $COMPOSE_CMD -f docker-compose/common.yml -f docker-compose/patched.yml rm -fv koha_patched
- $COMPOSE_CMD -f docker-compose/common.yml -f docker-compose/patched.yml build koha_patched
- $COMPOSE_CMD -f docker-compose/common.yml -f docker-compose/patched.yml up -d --force-recreate --no-deps koha_patched
- $COMPOSE_CMD -f docker-compose/common.yml -f docker-compose/patched.yml logs -f --no-color koha_patched
- mkdir -p ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- echo "$STAGING_PRIVATE_KEY" > ~/.ssh/id_rsa
- chmod 0600 ~/.ssh/id_rsa
# Deploy to debian repo at static.deichman.no
- rsync -av --delete $CI_PROJECT_DIR/koha-patched/debian/ $DEBIAN_REPO_INCOMING
# unpublish old repo
- ssh [email protected] "sudo docker run --rm --name aptly_docker -v $DEBIAN_REPO_DIR:/aptly digibib/aptly:latest
aptly publish drop wheezy" || true
# drop old snapshot
- ssh [email protected] "sudo docker run --rm --name aptly_docker -v $DEBIAN_REPO_DIR:/aptly digibib/aptly:latest
aptly snapshot drop koha-patched" || true
# add packages from incoming
- ssh [email protected] "sudo docker run --rm --name aptly_docker -v $DEBIAN_REPO_DIR:/aptly digibib/aptly:latest
aptly repo include -keyring=6DDE02B2 -accept-unsigned=true -repo=deichmankoha -architectures=amd64 /aptly/incoming"
# create new repo
- ssh [email protected] "sudo docker run --rm --name aptly_docker -v $DEBIAN_REPO_DIR:/aptly digibib/aptly:latest
aptly snapshot create -architectures=amd64 koha-patched from repo deichmankoha"
# publish
- ssh [email protected] "sudo docker run --rm --name aptly_docker -v $DEBIAN_REPO_DIR:/aptly digibib/aptly:latest
aptly publish snapshot -architectures=i386,amd64 -skip-signing=true koha-patched"
artifacts:
paths:
- koha-patched/debian
expire_in: 2 hrs
build_docker_image:
stage: deploy
only:
- tags
script:
- source docker-compose/docker-compose.env
- $COMPOSE_CMD -f docker-compose/ci.yml rm -fv koha_ci || true
- $COMPOSE_CMD -f docker-compose/ci.yml build koha_ci
- $COMPOSE_CMD -f docker-compose/ci.yml up -d --force-recreate --no-deps koha_ci
- docker exec -i koha_ci ./wait_until_ready.py
- $COMPOSE_CMD -f docker-compose/ci.yml stop koha_ci || true
- $COMPOSE_CMD -f docker-compose/ci.yml rm -fv koha_ci || true
- $COMPOSE_CMD -f docker-compose/ci.yml logs --no-color koha_ci
# push to docker hub
- docker login --username=$DOCKERHUB_USERNAME --password=$DOCKERHUB_PASSWORD
- docker push digibib/koha:$CI_COMMIT_SHA