-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
70 lines (63 loc) · 2.16 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
image: registry.gitlab.nxs360.com/docker/php:7.4-cli
stages:
- validation
- deploy
- release
tests:coverage:
stage: validation
script:
- composer validate
- composer install
- composer cs-check
- composer md-check
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
artifacts:
expire_in: 30 days
paths:
- tests/_output/
pages:
image: ruby:2.7
stage: deploy
script:
- "mv tests/_output/coverage/ public/"
artifacts:
expire_in: 30 days
paths:
- public
only:
- master
# https://gitlab.nxs360.com/help/user/packages/composer_repository/index#publish-a-composer-package-by-using-cicd
deploy:composer:
stage: deploy
script:
- version=$([[ -z "$CI_COMMIT_TAG" ]] && echo "branch=$CI_COMMIT_REF_NAME" || echo "tag=$CI_COMMIT_TAG")
- response=$(curl -s -w "\n%{http_code}" $insecure --data $version $URL)
- code=$(echo "$response" | tail -n 1)
- body=$(echo "$response" | head -n 1)
# Output state information
- |
if [ $code -eq 201 ]; then
echo "Package created - Code $code - $body";
else
echo "Could not create package - Code $code - $body";
exit 1
fi
variables:
URL: "${CI_API_V4_URL}/projects/$CI_PROJECT_ID/packages/composer?job_token=$CI_JOB_TOKEN"
rules:
- if: $CI_MERGE_REQUEST_ID
when: never
- if: $CI_COMMIT_TAG =~ /^?[0-9]+[.][0-9]+([.][0-9]+)?$/
# https://docs.gitlab.com/ee/user/project/releases/release_cicd_examples.html#create-a-release-when-a-git-tag-is-created
release_job:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG # Run this job when a tag is created
script:
- echo "running release_job"
release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
tag_name: '$CI_COMMIT_TAG'
description: '$CI_COMMIT_TAG'
variables:
COMPOSER_AUTH: '{"gitlab-oauth":{"gitlab.nxs360.com":"vnzsASLw7YzcAzPYN6_v"}}'