forked from firecow/gitlab-ci-local
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
84 lines (79 loc) · 2.21 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
84 lines (79 loc) · 2.21 KB
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
---
# @Description Install PHP packages
composer-install:
stage: build
image: composer
needs: []
artifacts:
paths: [vendor/]
cache:
key: composer-home
paths: [.composer/cache/]
variables:
COMPOSER_HOME: ".composer"
script:
- composer install --no-progress
# @Description Build/Push PHP image
build-php:
needs: [composer-install]
image: docker:cli
stage: build
artifacts:
reports:
dotenv: .build-php-env
script:
- IMAGE_NAME=fake/php
- IMAGE_PIPELINE_URL=${IMAGE_NAME}:${CI_PIPELINE_IID}
- docker build . -q -t ${IMAGE_PIPELINE_URL}
- echo "Built ./Dockerfile ${IMAGE_PIPELINE_URL}"
- echo "BUILD_PHP_IMAGE_URL=${IMAGE_PIPELINE_URL}" > .build-php-env
- |
if [ "${GITLAB_CI}" == 'true' ]; then
docker push -q ${IMAGE_PIPELINE_URL}
echo "Pushed ${IMAGE_PIPELINE_URL}"
fi
- |
if [ -n "${CI_COMMIT_TAG}" ]; then
IMAGE_TAG_URL=${IMAGE_NAME}:${CI_COMMIT_TAG}
docker tag ${IMAGE_PIPELINE_URL} ${IMAGE_TAG_URL}
docker push -q ${IMAGE_TAG_URL}
echo "Pushed ${IMAGE_TAG_URL}"
echo "BUILD_PHP_IMAGE_URL=${IMAGE_TAG_URL}" > .build-php-env
fi
# @Description Find PHP Code standard issues
php-cs-fixer-dry-run:
stage: test
image: php
needs: [composer-install]
rules:
- { if: $GITLAB_CI == 'false', allow_failure: true, when: on_success }
- { if: $GITLAB_CI == 'true', allow_failure: false, when: on_success }
script:
- vendor/bin/php-cs-fixer fix --dry-run --diff
# @Description Find outdated PHP packages
composer-outdated:
stage: test
image: composer
needs: [composer-install]
allow_failure: true
script:
- composer outdated --strict --direct
- echo "PHP packages are up to date"
# @Description Deploy a docker swarm stack
deploy:
needs: [build-php]
stage: deploy
script:
- docker stack deploy -c docker-compose.yml php-project
environment:
url: http://localhost:8892
name: local
# @Description Remove the deployed swarm stack (local only)
remove-stack:
stage: .post
needs: []
rules:
- { if: $GITLAB_CI == 'false', allow_failure: true, when: manual }
- { if: $GITLAB_CI == 'true', when: never }
script:
- docker stack rm php-project