-
Notifications
You must be signed in to change notification settings - Fork 29
/
.gitlab-ci.yml
179 lines (166 loc) · 5.48 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
---
image: docker:26.1.3-cli
services:
- name: docker:26.1.3-dind
command: ["--tls=false"]
stages:
- validate
- build
- test
- deploy
# ---
# Common workflow rules.
# ---
workflow:
rules:
## D10
- if: $CI_COMMIT_REF_NAME == "3.x-develop"
variables:
DEPLOY_TAG: "10.x-edge"
- if: $CI_COMMIT_REF_NAME == "3.x-master"
variables:
DEPLOY_TAG: "10.x-latest"
- if: $CI_COMMIT_REF_NAME =~ /^release\/3.x\//
variables:
DEPLOY_TAG: "10.x-beta"
## Release tags.
- if: $CI_COMMIT_TAG != null
variables:
DEPLOY_TAG: $CI_COMMIT_TAG
- if: $CI_COMMIT_REF_NAME =~ /^(feature|feat|fix)/
variables:
DEPLOY_TAG: "10.x-dev"
- when: always # Run the pipeline in other cases
# ---
# Alias definitions.
# ---
.variables: &variables
IMAGE_VERSION_TAG_PREFIX: ""
IMAGE_VERSION_TAG: ""
IMAGE_TAG_EDGE: $CI_COMMIT_SHA
DOCKER_HOST: tcp://localhost:2375
BUILDKIT_INLINE_CACHE: '1'
DOCKER_DRIVER: overlay2
GOSS_FILES_STRATEGY: cp
.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" == "10.x-latest" ]] && [ -z "$DEPLOY_LATEST" ]; then echo "DEPLOY_LATEST must be set to progress with 'latest' tags."; exit 1; fi
# Install ahoy into the runner image.
- |
os=$(uname -s | tr [:upper:] [:lower:]) && architecture=$(case $(uname -m) in x86_64 | amd64) echo "amd64" ;; aarch64 | arm64 | armv8) echo "arm64" ;; *) echo "amd64" ;; esac) \
&& wget -q https://github.com/ahoy-cli/ahoy/releases/download/v2.1.1/ahoy-bin-$os-$architecture -O /usr/local/bin/ahoy \
&& chmod +x /usr/local/bin/ahoy
- apk add bash curl jq
- cp .env.default .env
- sed -i -e "s/^GOVCMS_RELEASE_TAG.*/GOVCMS_RELEASE_TAG=$DEPLOY_TAG/" .env
# Determine and use latest distribution release branch if USE_LATEST_RELEASE_BRANCH is set
- |
if [ ! -z "$USE_LATEST_RELEASE_BRANCH" ]; then
echo "Determining latest release branch in use at govcms/govcms"
LATEST=$(curl -H "Authorization: token $GITHUB_TOKEN" -s 'https://api.github.com/repos/govCMS/GovCMS/branches?per_page=100' | jq -r '.[].name' | grep release | sort -r | head -n 1)
sed -i -e "s#^GOVCMS_PROJECT_VERSION.*#GOVCMS_PROJECT_VERSION=dev-$LATEST#" .env
fi
- cat .env
- 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
- |
cat << EOF > auth.json
{
"github-oauth": {
"github.com": "$GITHUB_TOKEN"
}
}
EOF
- docker swarm init
- docker secret create composer-auth auth.json
- ahoy --version
- ahoy build y
# ---
# Job Definitions
# ---
deploy:multiarch:
stage: deploy
variables:
<<: *variables
script:
# Install ahoy into the runner image.
- |
os=$(uname -s | tr [:upper:] [:lower:]) && architecture=$(case $(uname -m) in x86_64 | amd64) echo "amd64" ;; aarch64 | arm64 | armv8) echo "arm64" ;; *) echo "amd64" ;; esac) \
&& wget -q https://github.com/ahoy-cli/ahoy/releases/download/v2.1.1/ahoy-bin-$os-$architecture -O /usr/local/bin/ahoy \
&& chmod +x /usr/local/bin/ahoy
- apk add bash curl jq
- cp .env.default .env
- sed -i -e "s/^GOVCMS_RELEASE_TAG.*/GOVCMS_RELEASE_TAG=$DEPLOY_TAG/" .env
# Determine and use latest distribution release branch if USE_LATEST_RELEASE_BRANCH is set
- |
if [ ! -z "$USE_LATEST_RELEASE_BRANCH" ]; then
echo "Determining latest release branch in use at govcms/govcms"
LATEST=$(curl -H "Authorization: token $GITHUB_TOKEN" -s 'https://api.github.com/repos/govCMS/GovCMS/branches?per_page=100' | jq -r '.[].name' | grep release | sort -r | head -n 1)
sed -i -e "s#^GOVCMS_PROJECT_VERSION.*#GOVCMS_PROJECT_VERSION=dev-$LATEST#" .env
fi
- cat .env
- docker buildx create --name govcms-amd-arm --platform linux/amd64,linux/arm64
- 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:
- 1.x-develop
- 2.x-develop
- 3.x-develop
- 1.x-master
- 2.x-master
- 3.x-master
- /^release\/2.x\//
- /^release\/3.x\//
- tags
needs:
- test:ahoy
validate:images:
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"
info:modules:
stage: build
variables:
<<: *variables
<<: *before_script_build
script:
- ahoy -v install -- install_configure_form.update_status_module='array(FALSE,FALSE)'
- docker compose exec -T cli drush status
# @todo: 10.x support.
#- /govcms/vendor/bin/govcms-module_verify
only:
- schedules
artifacts:
paths:
- $CSV_LOCATION
test:ahoy:
stage: test
variables:
<<: *variables
<<: *before_script_build
script:
- ahoy up
- ahoy test-$AHOY_TEST
parallel:
matrix:
- AHOY_TEST:
- 'goss'
- 'redis'
- 'install'
- 'nginx'
needs:
- build:images