Skip to content

Commit

Permalink
Add in features from the GitHub installer
Browse files Browse the repository at this point in the history
  • Loading branch information
justafish committed Nov 29, 2023
1 parent 78c352d commit 2d12663
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ build:
script:
- !reference [.drainpipe_setup_drupal, script]
- !reference [.drainpipe_setup_ddev, script]
- ddev start
- ddev composer config extra.drupal-scaffold.gitignore true
- ddev composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe\"]
- ddev composer config --json extra.drainpipe.gitlab \[]
- ddev composer config --no-plugins allow-plugins.composer/installers true
- ddev composer config --no-plugins allow-plugins.drupal/core-composer-scaffold true
- ddev composer config --no-plugins allow-plugins.lullabot/drainpipe true
Expand Down
45 changes: 38 additions & 7 deletions scaffold/gitlab/DDEV.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,52 @@ default:
alias: docker

variables:
DRAINPIPE_DDEV_SSH_PRIVATE_KEY:
DRAINPIPE_DDEV_SSH_KNOWN_HOSTS:
DRAINPIPE_DDEV_GIT_EMAIL:
DRAINPIPE_DDEV_GIT_NAME:
DRAINPIPE_DDEV_COMPOSER_CACHE_DIR:
DRAINPIPE_DDEV_VERSION:
DRAINPIPE_DDEV_SSH_PRIVATE_KEY: ""
DRAINPIPE_DDEV_SSH_KNOWN_HOSTS: ""
DRAINPIPE_DDEV_GIT_EMAIL: [email protected]
DRAINPIPE_DDEV_GIT_NAME: Drainpipe Bot
DRAINPIPE_DDEV_COMPOSER_CACHE_DIR: ""
DRAINPIPE_DDEV_VERSION: ""
DOCKER_HOST: "tcp://docker:2375"
FF_NETWORK_PER_BUILD: 1

.drainpipe_setup_ddev:
script:
- sudo chown -R runner:runner $CI_PROJECT_DIR
- curl -fsSL https://ddev.com/install.sh | bash
- |
mkdir -p .ddev/homeadditions/.ssh
# Copy private key
if [ "$DRAINPIPE_DDEV_SSH_PRIVATE_KEY" != "" ]; then
echo "$DRAINPIPE_DDEV_SSH_PRIVATE_KEY" > .ddev/homeadditions/.ssh/id_rsa
chmod 600 .ddev/homeadditions/.ssh/id_rsa
fi
# Copy known hosts
if [ "$DRAINPIPE_DDEV_SSH_KNOWN_HOSTS" != "" ]; then
echo "$DRAINPIPE_DDEV_SSH_KNOWN_HOSTS" > .ddev/homeadditions/.ssh/known_hosts
chmod 644 .ddev/homeadditions/.ssh/known_hosts
fi
# SSH config file
touch .ddev/homeadditions/.ssh/config
chmod 600 .ddev/homeadditions/.ssh/config
chmod 700 .ddev/homeadditions/.ssh
- |
if [ "$DRAINPIPE_DDEV_VERSION" != "" ]; then
curl -fsSL https://ddev.com/install.sh | bash -s "v$DRAINPIPE_DDEV_VERSION"
else
curl -fsSL https://ddev.com/install.sh | bash
fi
- ddev config global --no-bind-mounts
- if [ ! -f ".ddev/config.yaml" ]; then ddev config --auto; fi
- |
if [ "$DRAINPIPE_DDEV_COMPOSER_CACHE_DIR" != "false" ]; then
# @todo Replace /var/www/html with an environment variable.
CACHE_DIR=".ddev/.drainpipe-composer-cache"
if [ "$DRAINPIPE_DDEV_COMPOSER_CACHE_DIR" != "" ]; then
CACHE_DIR="$DRAINPIPE_DDEV_COMPOSER_CACHE_DIR"
fi
ddev config --web-environment-add="COMPOSER_CACHE_DIR=/var/www/html/$CACHE_DIR"
fi
- ddev start
- ddev describe
# Copy git credentials
Expand Down
10 changes: 8 additions & 2 deletions src/ScaffoldInstallerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,14 @@ private function installCICommands(): void
$fs->removeDirectory('./.drainpipe/gitlab');
if (isset($this->extra['drainpipe']['gitlab']) && is_array($this->extra['drainpipe']['gitlab'])) {
$fs->ensureDirectoryExists('./.drainpipe/gitlab');
$fs->copy("$scaffoldPath/gitlab/Common.gitlab-ci.yml", ".drainpipe/gitlab/Common.gitlab-ci.yml");
$this->io->write("🪠 [Drainpipe] .drainpipe/gitlab/Common.gitlab-ci.yml installed");
if (file_exists('./.ddev/config.yaml')) {
$fs->copy("$scaffoldPath/gitlab/DDEV.gitlab-ci.yml", ".drainpipe/gitlab/DDEV.gitlab-ci.yml");
$this->io->write("🪠 [Drainpipe] .drainpipe/gitlab/DDEV.gitlab-ci.yml installed");
}
else {
$fs->copy("$scaffoldPath/gitlab/Common.gitlab-ci.yml", ".drainpipe/gitlab/Common.gitlab-ci.yml");
$this->io->write("🪠 [Drainpipe] .drainpipe/gitlab/Common.gitlab-ci.yml installed");
}
foreach ($this->extra['drainpipe']['gitlab'] as $gitlab) {
$file = "gitlab/$gitlab.gitlab-ci.yml";
if (file_exists("$scaffoldPath/$file")) {
Expand Down

0 comments on commit 2d12663

Please sign in to comment.