Last active
October 26, 2023 10:09
-
-
Save t3easy/37d7d58294e785797c076e20b41c67b6 to your computer and use it in GitHub Desktop.
TYPO3 Surf in GitLab CI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cache: | |
key: "$CI_JOB_STAGE-$CI_COMMIT_REF_NAME" | |
paths: | |
- .cache/ | |
.dedicated-runner: | |
tags: | |
- docker | |
- linux | |
.composer: | |
extends: .dedicated-runner | |
image: t3easy/surf:next | |
stage: test | |
before_script: | |
- eval $(ssh-agent -s) | |
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null | |
- mkdir -p ~/.ssh | |
- chmod 700 ~/.ssh | |
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts | |
- chmod 644 ~/.ssh/known_hosts | |
check-outdated: | |
extends: .composer | |
allow_failure: true | |
script: | |
- composer install --no-ansi --no-interaction --no-dev --no-progress --no-scripts | |
- composer outdated -D -m --strict --no-ansi --no-interaction | |
.deploy: | |
extends: .composer | |
stage: deploy | |
except: | |
- schedules | |
deploy:staging: | |
extends: .deploy | |
only: | |
- develop | |
variables: | |
COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/.cache/composer" | |
YARN_CACHE_FOLDER: "$CI_PROJECT_DIR/.cache/yarn" | |
BASE_URL: https://staging.domain.tld/ | |
DEPLOYMENT_PATH: /html/staging.domain.tld | |
TYPO3_CONTEXT: Production/Staging | |
script: | |
- surf deploy typo3 | |
deploy:live: | |
extends: .deploy | |
only: | |
- master | |
variables: | |
COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/.cache/composer" | |
YARN_CACHE_FOLDER: "$CI_PROJECT_DIR/.cache/yarn" | |
BASE_URL: https://www.domain.tld/ | |
DEPLOYMENT_PATH: /html/www.domain.tld | |
TYPO3_CONTEXT: Production | |
script: | |
- surf deploy typo3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "my/typo3-distribution", | |
"description": "TYPO3 CMS Distribution", | |
"license": "GPL-2.0-or-later", | |
"require": { | |
"aoepeople/crawler": "^6.4.1", | |
"dmitryd/typo3-dd-googlesitemap": "^2.1", | |
"dmitryd/typo3-realurl": "^2.3", | |
"helhum/typo3-console": "^5.3", | |
"helhum/typo3-secure-web": "^0.2.8", | |
"typo3/cms-about": "^8.7.10", | |
"typo3/cms-belog": "^8.7.10", | |
"typo3/cms-beuser": "^8.7.10", | |
"typo3/cms-context-help": "^8.7.10", | |
"typo3/cms-documentation": "^8.7.10", | |
"typo3/cms-felogin": "^8.7.10", | |
"typo3/cms-fluid-styled-content": "^8.7.10", | |
"typo3/cms-form": "^8.7.10", | |
"typo3/cms-func": "^8.7.10", | |
"typo3/cms-impexp": "^8.7.10", | |
"typo3/cms-indexed-search": "^8.7.10", | |
"typo3/cms-info": "^8.7.10", | |
"typo3/cms-info-pagetsconfig": "^8.7.10", | |
"typo3/cms-linkvalidator": "^8.7.10", | |
"typo3/cms-opendocs": "^8.7.10", | |
"typo3/cms-recycler": "^8.7.10", | |
"typo3/cms-reports": "^8.7.10", | |
"typo3/cms-rte-ckeditor": "^8.7.10", | |
"typo3/cms-setup": "^8.7.10", | |
"typo3/cms-t3editor": "^8.7.10", | |
"typo3/cms-tstemplate": "^8.7.10", | |
"typo3/cms-viewpage": "^8.7.10", | |
"typo3/cms-wizard-crpages": "^8.7.10", | |
"typo3/cms-wizard-sortpages": "^8.7.10" | |
}, | |
"require-dev": { | |
"friendsoftypo3/extension-builder": "^8.7", | |
"ichhabrecht/filefill": "^3.0.1", | |
"nimut/testing-framework": "^4.1", | |
"typo3/cms-lowlevel": "^8.7.10" | |
}, | |
"config": { | |
"gitlab-domains": [ | |
"gitlab.com", | |
"gitlab.internal.corp.tld" | |
], | |
"platform": { | |
"php": "7.2" | |
}, | |
"sort-packages": true | |
}, | |
"extra": { | |
"typo3/cms": { | |
"cms-package-dir": "{$vendor-dir}/typo3/cms", | |
"root-dir": "private", | |
"web-dir": "public" | |
} | |
}, | |
"repositories": [ | |
{ | |
"type": "path", | |
"url": "packages/*" | |
} | |
], | |
"scripts": { | |
"post-autoload-dump": [ | |
"@typo3-cms-scripts" | |
], | |
"build": [ | |
"yarn --cwd private/typo3conf/ext/sitepackage run build" | |
], | |
"build-dev": [ | |
"yarn --cwd private/typo3conf/ext/sitepackage run build-dev" | |
], | |
"typo3-cms-scripts": [ | |
"typo3cms install:fixfolderstructure", | |
"typo3cms install:generatepackagestates" | |
] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** @var \TYPO3\Surf\Domain\Model\Deployment $deployment */ | |
$node = new \TYPO3\Surf\Domain\Model\Node('server1234.myhoster.tld'); | |
$node | |
->setHostname($node->getName()) | |
->setOption('username', 'user1234') | |
->setOption('phpBinaryPathAndFilename', '/usr/local/bin/php_cli'); | |
$application = new \TYPO3\Surf\Application\TYPO3\CMS(); | |
$application | |
->setContext(getenv('TYPO3_CONTEXT')) | |
->setDeploymentPath(getenv('DEPLOYMENT_PATH')) | |
->setOption('baseUrl', getenv('BASE_URL')) | |
->setOption('composerCommandPath', 'composer') | |
->setOption('keepReleases', 3) | |
->setOption('webDirectory', 'public') | |
->setOption('repositoryUrl', getenv('CI_REPOSITORY_URL') !== false ? getenv('CI_REPOSITORY_URL') : 'file://' . dirname(__DIR__)) | |
->setOption('branch', getenv('CI_COMMIT_REF_NAME') !== false ? getenv('CI_COMMIT_REF_NAME') : 'master') | |
->setOption('symlinkDataFolders', ['fileadmin', 'uploads']) | |
->setOption('rsyncExcludes', [ | |
'.git*', | |
'.surf', | |
'private/fileadmin', | |
'private/typo3conf/ext/**.sass', | |
'private/uploads', | |
]) | |
->addSymlink($application->getOption('webDirectory') . '/typo3conf/LocalConfiguration.php', '../../../../shared/Configuration/LocalConfiguration.php') | |
->addNode($node); | |
$deployment | |
->addApplication($application) | |
->onInitialize( | |
function () use ($deployment, $application) { | |
$deployment->getWorkflow() | |
->defineTask($executeAllUpgradeWizards = 'My\\TYPO3\\Distribution\\DefinedTask\\ExecuteAllUpgradeWizards', \TYPO3\Surf\Task\TYPO3\CMS\RunCommandTask::class, [ | |
'command' => 'upgrade:all' | |
]) | |
->defineTask($generateOfflineSitemap = 'My\\TYPO3\\Distribution\\DefinedTask\\GenerateOfflineSitemap', \TYPO3\Surf\Task\TYPO3\CMS\RunCommandTask::class, [ | |
'command' => 'scheduler:run', | |
'arguments' => ['1', '--force'], | |
]) | |
->defineTask( | |
$build = 'My\\TYPO3\\Distribution\\DefinedTask\\Build', | |
\TYPO3\Surf\Task\Composer\CommandTask::class, | |
[ | |
'nodeName' => 'localhost', | |
'useApplicationWorkspace' => true, | |
'command' => 'run-script', | |
'additionalArguments' => ['build'] | |
] | |
) | |
->afterTask('TYPO3\\Surf\\DefinedTask\\Composer\\LocalInstallTask', [ | |
$build, | |
], $application) | |
->beforeTask(\TYPO3\Surf\Task\TYPO3\CMS\SetUpExtensionsTask::class, [ | |
$executeAllUpgradeWizards, | |
], $application) | |
->beforeStage('transfer', \TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask::class, $application) | |
->afterStage('switch', [ | |
\TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask::class, | |
$generateOfflineSitemap, | |
], $application) | |
->removeTask(\TYPO3\Surf\Task\TYPO3\CMS\CreatePackageStatesTask::class, $application) | |
->removeTask(\TYPO3\Surf\Task\TYPO3\CMS\CopyConfigurationTask::class, $application); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment