This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy path.gitlab-ci.yml
126 lines (114 loc) · 3.25 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---
image: gitlab-registry-production.govcms.amazee.io/govcms/govcms-ci/govcms-ci-buildx
services:
- name: gitlab-registry-production.govcms.amazee.io/govcms/govcms-ci/dind:latest
command: ["--tls=false"]
stages:
- validate
- build
- test
- deploy
# ---
# Common workflow rules.
# ---
workflow:
rules:
- if: $CI_COMMIT_REF_NAME == "develop"
variables:
DEPLOY_TAG: "edge"
- if: $CI_COMMIT_REF_NAME == "master"
variables:
DEPLOY_TAG: "latest"
- if: $CI_COMMIT_REF_NAME =~ /^release\//
variables:
DEPLOY_TAG: "beta"
## Release tags.
- if: $CI_COMMIT_TAG != null
variables:
DEPLOY_TAG: $CI_COMMIT_TAG
- when: always # Run the pipeline in other cases
# ---
# Alias definitions.
# ---
.variables: &variables
DOCKER_HOST: tcp://localhost:2375
BUILDKIT_INLINE_CACHE: '1'
DOCKER_DRIVER: overlay2
.before_script_build: &before_script_build
before_script:
- if [ -z "$DEPLOY_TAG" ]; then echo "DEPLOY_TAG must be set for an actionable build."; exit 1; fi
# Latest tags need a confirmation var (provided manually: DEPLOY_LATEST)
- if [[ "$DEPLOY_TAG" == "latest" ]] && [ -z "$DEPLOY_LATEST" ]; then echo "DEPLOY_LATEST must be set to progress with 'latest' tags."; exit 1; fi
- cp .env.default .env
- sed -i -e "s/^GOVCMS_RELEASE_TAG.*/GOVCMS_RELEASE_TAG=$DEPLOY_TAG/" .env
- cat .env
- update-binfmts --enable # Important: Ensures execution of other binary formats is enabled in the kernel
- export $(grep -v '^#' .env | xargs)
- docker network prune -f && docker network inspect amazeeio-network >/dev/null || docker network create amazeeio-network
- docker login -u $DOCKER_USER -p $DOCKER_PASS
- ahoy build y
- docker image list
validate:images:
variables:
<< : *variables
stage: validate
script:
- docker-compose config -q
build:images:
stage: build
variables:
<<: *variables
DOCKER_REGISTRY_HOST: $CI_REGISTRY/
<<: *before_script_build
script:
- echo "Build successful"
needs:
- validate:images
test:ahoy: &test
stage: test
variables:
<<: *variables
<<: *before_script_build
script:
- ahoy up
- ahoy -v install || true
- ahoy test-phpunit
- ahoy drush status
needs:
- build:images
test:module_scanning:
<< : *test
stage: test
script:
- ahoy up
- ahoy -v install || true
- /govcms/vendor/bin/govcms-module_verify
needs:
- build:images
artifacts:
paths:
- $CSV_LOCATION
only:
- schedules
deploy:multiarch:
stage: deploy
variables:
<<: *variables
script:
- cp .env.default .env
- sed -i -e "s/^GOVCMS_RELEASE_TAG.*/GOVCMS_RELEASE_TAG=$DEPLOY_TAG/" .env
- cat .env
- update-binfmts --enable # Important: Ensures execution of other binary formats is enabled in the kernel
- docker buildx create --name govcms-amd-arm --platform linux/amd64,linux/arm64 tcp://localhost:2375
- docker buildx ls
- export $(grep -v '^#' .env | xargs)
- docker network prune -f && docker network inspect amazeeio-network >/dev/null || docker network create amazeeio-network
- docker login -u $DOCKER_USER -p $DOCKER_PASS
- ahoy publish y
only:
- develop
- master
- /^release\//
- tags
needs:
- test:ahoy