Collection of reusable GitLab steps.
include:
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/.deploy-prepare.yml'
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/build-php.yml'
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/build-node.yml'
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/test-composer-normalize.yml'
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/test-editorconfig-lint.yml'
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/test-composer-sitepackage.yml'
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/test-es-lint.yml'
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/test-language-lint.yml'
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/test-html-lint.yml'
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/test-php-lint.yml'
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/test-php-cs-fixer.yml'
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/test-php-stan.yml'
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/test-php-unit.yml'
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/test-php-functional.yml'
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/test-typoscript-lint.yml'
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/test-yaml-lint.yml'
- remote: 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.6.0/deploy.yml'
inputs:
ci_server_url: https://git.example.com
live_environment_url: 'https://example.com/'
test_environment_url: 'https://test.example.com/'-
[No stage]
.deploy-prepare.yml
-
build
build-phpbuild-php-no-devbuild-php-v11build-node⚠️ needs configuration
-
reset
reset-upload-source⚠️ needs configurationreset-download-target⚠️ needs configuration
-
test
test-composer-normalizetest-editorconfig-linttest-composer-sitepackage⚠️ needs configurationtest-es-lint⚠️ needs configurationtest-html-lint⚠️ needs configurationtest-language-linttest-php-linttest-php-cs-fixertest-php-stantest-php-unittest-php-functionaltest-typoscript-linttest-xml-lint⛔️ deprecatedtest-yaml-lint
-
docker.build
-
deploy.dev
-
test.dev
-
deploy.test
deploy-test
-
test.test
-
release
-
deploy.live
deploy-livedeploy-live-warmup
-
test.live
You can set custom options for the composer install command via environment variable:
variables:
COMPOSER_INSTALL_OPTIONS: "--ignore-platform-req=ext-ldap"
include:
- 'https://raw.githubusercontent.com/xima-media/gitlab-templates/1.0.0/build-php.yml'Add this to your .gitlab-ci.yml and configure the path of the composer.json of your sitepackage:
test-composer-sitepackage:
script:
- php sitepackage-req-checker.php packages/sitepackage_name/composer.json --ci=sitepackage-req-checker-report.xmlAdd this to your .gitlab-ci.yml to configure the node version and asset paths:
build-node:
image:
name: node:18.17.1-slim
artifacts:
paths:
- packages/xm_dkfz_net_site/Resources/Public/Css/dist
- packages/xm_dkfz_net_site/Resources/Public/JavaScript/distAdd this to your .gitlab-ci.yml to configure the node version:
test-es-lint:
image:
name: node:18.17.1-slimAdd this to your .gitlab-ci.yml to configure the node version:
test-html-lint:
image:
name: node:18.17.1-slimReset jobs are useful for syncing assets and databases between environments.
Rclone supports various storage providers to accomplish that:
- S3 remote for file storage
- CRYPT remote for client-side encryption to S3 remote
- SFTP remote for synchronisation with SSH hosts.
- PHP Deployer deploy.php with SSH hosts
- S3 storage provider
- Gitlab file variable in project settings:
RCLONE_RESET_STORAGE_ENV
RCLONE_RESET_STORAGE_ENV
# Rclone configuration with environment variables for S3 backend: https://rclone.org/docs/#config-file and https://rclone.org/s3/
RCLONE_CONFIG_STORAGE_TYPE=s3
RCLONE_CONFIG_STORAGE_PROVIDER=AWS
RCLONE_CONFIG_STORAGE_ACCESS_KEY_ID=<secret>
RCLONE_CONFIG_STORAGE_SECRET_ACCESS_KEY=<secret>
RCLONE_CONFIG_STORAGE_ENDPOINT=eu-central-1
RCLONE_CONFIG_STORAGE_REGION=EU
RCLONE_CONFIG_STORAGE_ACL=private
# Crypt remote for client-side encryption is created on the fly from these variables in *.reset-prepare* job
# GitLab CI/CD variable expansion must be disabled!
CRYPT_NAME=<crypt_name>
CRYPT_REMOTE="storage:<s3-bucket-name>/${CRYPT_NAME}"
CRYPT_PASSWORD=<secret>
CRYPT_PASSWORD2=<secret>Configurable defaults for synced directories, file types and sizes are set in input specs of reset.yml.
Notes about variables:
- RESET_JOB must be set to "true" to trigger reset jobs.
- RESET_UPLOAD_SOURCE_SELECTOR and RESET_DOWNLOAD_TARGET_SELECTOR can match host names or labels defined in deploy.php:
- RESET_UPLOAD_SOURCE_SELECTOR == 'hostname'
- RESET_DOWNLOAD_TARGET_SELECTOR == 'label=value'
- RESET_UPLOAD_SOURCE_SELECTOR defaults to stage=live when unset.
- reset-download-target aborts if the last deployed commit branch on target does not match
$CI_COMMIT_BRANCHfor which the pipeline is run.
Default behaviour:
RESET_JOB == "true"andRESET_DOWNLOAD_TARGET_SELECTOR,RESET_UPLOAD_SOURCE_SELECTORunset -> triggers reset-upload-sourceRESET_JOB == "true"andRESET_UPLOAD_SOURCE_SELECTOR == '<selector>'-> triggers reset-upload-source for hostRESET_JOB == "true"andRESET_DOWNLOAD_TARGET_SELECTOR == '<selector>'-> Triggers reset-download-target for , which validates that this selector already is a deployment target of the $CI_COMMIT_BRANCH from which the pipeline was run before importing assets + database, followed up by deploy-test if applicable (no Release created in this case!).
Gitlab CI schedules for periodic resets are set as follows:
-
Name: 'Upload data from live instance(s) in deploy.php'
- Cron: '0 14 * * 0'
- Variables:
- RESET_JOB == "true"
- RESET_UPLOAD_SOURCE_SELECTOR == "stage=live"
- Run for branch name:
- Any, does not need to match "stage=live" for upload.
-
Name: 'Reset test instance(s) in deploy.php to previously uploaded data'
- Cron: '0 15 * * 0'
- Variables:
- RESET_JOB == "true"
- RESET_DOWNLOAD_TARGET_SELECTOR == "stage=test"
- Run for branch name:
- Branch that is already associated with hosts matching 'stage=test'.
Jobs can be triggered manually from a pipeline using Gitlab UI with the same variables:
- Reset host 'xyz' in deploy.php to previously uploaded data
- Variables:
- RESET_JOB == "true"
- RESET_DOWNLOAD_TARGET_SELECTOR == "xyz"
- Run for branch name:
- Branch that is already associated with host 'xyz'.
- Variables: