Skip to content

Latest commit

Β 

History

142 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GitLab-CI Templates

CGL License

This repository provides useful templates for reusable GitLab-CI jobs in move:elevator projects. It is not meant to be used anywhere else.

πŸ”₯ Installation

See .gitlab-ci.yml.dist for an example GitLab-CI configuration.

Use include to reference template files:

include:
   - 'https://raw.githubusercontent.com/move-elevator/gitlab-ci-templates/main/.base.yml'
   - 'https://raw.githubusercontent.com/move-elevator/gitlab-ci-templates/main/build/build-php.yml'
   - ...

Extend and override configuration variables, see .base.yaml for predefined variables.

variables:
  BUILD_NODE_VERSION: "22"

Extend and override further ci jobs.

πŸ“‚ Templates

  • .base.yml: Base configuration, including common variables and stages, required for all projects.

Build

Build the project and its assets.

Includes:

  • build/build-php.yml
  • build/build-node.yaml

Analysis

Analyze code quality and static analysis.

Includes:

  • analyze/analyze-composer-lint.yaml
  • analyze/analyze-content-blocks-lint.yaml
  • analyze/analyze-editorconfig.yaml
  • analyze/analyze-fluid-lint.yaml
  • analyze/analyze-js-lint.yaml
  • analyze/analyze-php-cs-fixer.yaml
  • analyze/analyze-php-rector.yaml
  • analyze/analyze-php-stan.yaml
  • analyze/analyze-style-lint.yaml
  • analyze/analyze-typoscript-lint.yaml
  • analyze/analyze-xml-lint.yaml
  • analyze/analyze-yaml-lint.yaml

Note

The analyze jobs have changes triggers for the respective files, so they only run when relevant files are changed.

Feature Branch Deployment

Deploy feature branches to a dedicated environment.

The deployment uses deployer and deployer-tools as deployment base.

Includes:

  • deploy/deploy-feature.yaml
  • deploy/deploy-feature-rollback.yaml
  • deploy/deploy-feature-cleanup.yaml
  • deploy/deploy-feature-cleanup-downstream.yaml

Note

The cleanup of a feature branch is a little bit tricky. It may happen that the branch has been deleted, triggering the deploy:feature:cleanup job. However, since the application code in the branch is no longer available at this point and the cleanup logic and configuration are therefore no longer present, the cleanup is delegated to another branch (usually the main branch) via the downstream pipeline.

Prod Deployment

Deployment to production environment.

The deployment uses deployer and deployer-tools as deployment base.

Includes:

  • deploy/deploy-prod.yaml
  • deploy/deploy-prod-rollback.yaml

Important

Production deployments are restricted to semver-tagged versions only (e.g. v1.2.3 or 1.2.3).

Stage Deployment

Deployment to staging environment.

The deployment uses deployer and deployer-tools as deployment base.

Includes:

  • deploy/deploy-stage.yaml

Note

Use this template if the project wants a simple stage deployment and doesn't need an advanced feature branch deployment.

Release

Create a GitLab release with release notes.

Includes:

  • build/build-release-notes.yaml
  • release/release.yaml

The release notes come from one of two mutually exclusive templates β€” include exactly one:

  • build/build-release-notes.yaml: fetches them from GitLab's changelog API.
  • build/build-release-notes-changelog.yaml: extracts the section for the current tag from CHANGELOG.md. Use this one for projects whose changelog is generated from conventional commits, which the GitLab API does not understand.

The asset link on the release page defaults to the project's container image and is overridden with RELEASE_ASSET_LINK_NAME and RELEASE_ASSET_LINK_URL.

Automated releases

Includes:

  • release/release-prepare.yaml
  • build/build-release-notes-changelog.yaml
  • release/release.yaml

release:prepare is a manual job on the default branch that bumps the version, generates CHANGELOG.md, folds both into one chore(release): version X.Y.Z commit authored by whoever pressed the button, and pushes the commit (with ci.skip) and the tag. The tag pipeline then builds the release notes, publishes the GitLab Release and deploys to production.

It needs version-bumper with a version-bumper.yaml, an npm script changelog, and a masked, protected RELEASE_TOKEN variable holding a token with write_repository scope.

Important

Only users who may push to a protected branch can run manual jobs on it. Protect the default branch and set "Allowed to push and merge" to the people who may release β€” that, and not the job definition, is what restricts who can cut a release.

Note

Set RELEASE_DRY_RUN to any value when starting the job to rehearse a release: everything runs, but both pushes become git push --dry-run. With it set the job is also offered on non-default branches.

Testing

Run acceptance tests using Codeception.

Includes:

  • test/test-feature-codeception.yaml
  • test/test-prod-codeception.yaml

Cache Warmup

Warm up the cache after deployment using EXT:typo3-warming.

Includes:

  • cache/cache-feature-warmup.yaml
  • cache/cache-prod-warmup.yaml

Security

Run security checks using audit tools.

Includes:

  • security/security-composer-check-scheduled.yaml
  • security/security-npm-check-scheduled.yaml

Note

The *:scheduled jobs above need to be scheduled in GitLab-CI.

Important

A pipeline schedule needs to have set the variable SCHEDULE_TASK_NAME to the desired task, e.g. security:composer:check:scheduled or security:npm:check:scheduled. This is a workaround (see according rules) to address specific jobs in a scheduled pipeline.

Generate a CycloneDX SBOM (Software Bill of Materials) of all locked composer and npm dependencies using syft. The SBOM is stored as job artifact and published to the project's Generic Package Registry, which serves as technical documentation in terms of the Cyber Resilience Act (CRA).

Includes:

  • security/security-sbom.yaml

Runs on semantic version tags only, matching the prod deployment. Published as packages/generic/sbom/<version>/sbom.cdx.json, where <version> is the tag without a leading v. Dev dependencies are excluded, so the SBOM describes the shipped application rather than the build toolchain.

Important

Technical documentation has to be kept for the declared support period. Make sure the project has no cleanup policy that removes generic packages.

⭐ License

This project is licensed under GNU General Public License 3.0 (or later).

About

πŸ“‘ Collection of useful GitLab CI templates.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Contributors