forked from backdrop/backdrop
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request backdrop#13 from backdrop/1.x
update
- Loading branch information
Showing
35 changed files
with
286 additions
and
100 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
services: | ||
php: | ||
image: tugboatqa/php:7.2-apache | ||
default: true | ||
depends: mariadb | ||
commands: | ||
init: | ||
# Install PHP 'zip' extension to allow installing Backdrop modules. | ||
- docker-php-ext-install zip | ||
# Enable Apache 'rewrite' module for clean URLs. | ||
- a2enmod rewrite | ||
# Link the document root to the expected path. | ||
- ln -snf $TUGBOAT_ROOT $DOCROOT | ||
update: | ||
# Use the Tugboat-specific Backdrop settings. | ||
- cp $TUGBOAT_ROOT/.tugboat/settings.local.php $TUGBOAT_ROOT/settings.local.php | ||
# Generate a unique hash_salt to secure the site. | ||
- echo "\$settings['hash_salt'] = '$(openssl rand -hex 32)';" >> $TUGBOAT_ROOT/settings.local.php | ||
# Create the config directories. | ||
- mkdir $TUGBOAT_ROOT/files/config | ||
- mkdir $TUGBOAT_ROOT/files/config/active | ||
- mkdir $TUGBOAT_ROOT/files/config/staging | ||
# Set appropriate file permissions/ownership. | ||
- chown -R www-data:www-data $TUGBOAT_ROOT | ||
- find $TUGBOAT_ROOT/files $TUGBOAT_ROOT/layouts $TUGBOAT_ROOT/modules $TUGBOAT_ROOT/themes -type d -exec chmod 2775 {} \; | ||
- find $TUGBOAT_ROOT/files $TUGBOAT_ROOT/layouts $TUGBOAT_ROOT/modules $TUGBOAT_ROOT/themes -type f -exec chmod 0664 {} \; | ||
build: | ||
# Delete previous comments in the PR. | ||
- cd $TUGBOAT_ROOT/.tugboat && ./delete-comments.sh | ||
# Clear out active config (needed when rebuilding/reinstalling). | ||
- find $TUGBOAT_ROOT/files/config/active -mindepth 1 -delete | ||
# Generate and store a random password for the admin user. | ||
- openssl rand -hex 6 > $TUGBOAT_ROOT/.tugboat/password | ||
# Install Backdrop. | ||
- cd $TUGBOAT_ROOT && ./core/scripts/install.sh --db-url=mysql://tugboat:tugboat@mariadb/tugboat --account-pass=`cat .tugboat/password` | ||
# Fix config permissions after install. | ||
- chown -R www-data:www-data $TUGBOAT_ROOT/files/config/active | ||
- find $TUGBOAT_ROOT/files/config/active -type f -exec chmod 0664 {} \; | ||
# Post a comment in the PR. | ||
- cd $TUGBOAT_ROOT/.tugboat && ./post-comment.sh | ||
mariadb: | ||
image: tugboatqa/mariadb:latest | ||
commands: | ||
init: | ||
# Configure database for UTF-8: https://api.backdropcms.org/database-configuration#utf8mb4 | ||
- echo "[mysqld]\ninnodb_large_prefix=true\ninnodb_file_format=barracuda\ninnodb_file_per_table=true" >> /etc/mysql/conf.d/utf8mb.conf | ||
build: | ||
# Drop and re-create the database (needed when rebuilding/reinstalling). | ||
- mysqladmin -f drop tugboat && mysqladmin create tugboat |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
/** | ||
* Delete any previous comments in the PR about this preview. | ||
*/ | ||
|
||
$curl_header = array( | ||
'Authorization: token ' . getenv('BACKDROP_GITHUB_TOKEN'), | ||
'Content-Type: application/json', | ||
'Accept: application/vnd.github.v3+json', | ||
'User-Agent: Backdrop CMS', | ||
); | ||
$text = 'Tugboat has finished building a preview for this pull request!'; | ||
$url = getenv('TUGBOAT_DEFAULT_SERVICE_URL'); | ||
|
||
// Get all comments in this PR. | ||
$ch = curl_init('https://api.github.com/repos/' . getenv('TUGBOAT_GITHUB_OWNER') . '/' . getenv('TUGBOAT_GITHUB_REPO') . '/issues/' . getenv('TUGBOAT_GITHUB_PR') . '/comments'); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_header); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | ||
$response = curl_exec($ch); | ||
$code = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); | ||
curl_close($ch); | ||
|
||
// Find comments that match the new one we're about to add. | ||
if ($code == 200) { | ||
foreach (json_decode($response) as $comment) { | ||
if (strpos($comment->body, $text) === 0 && strpos($comment->body, $url) !== FALSE) { | ||
// Delete comment. | ||
$ch = curl_init('https://api.github.com/repos/' . getenv('TUGBOAT_GITHUB_OWNER') . '/' . getenv('TUGBOAT_GITHUB_REPO') . '/issues/comments/' . $comment->id); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_header); | ||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | ||
curl_exec($ch); | ||
curl_close($ch); | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
/** | ||
* Post a comment in the PR with login details. | ||
*/ | ||
|
||
$password = file_get_contents(getenv('TUGBOAT_ROOT') . '/.tugboat/password'); | ||
$comment = 'Tugboat has finished building a preview for this pull request! | ||
Website: ' . getenv('TUGBOAT_DEFAULT_SERVICE_URL') . ' | ||
Username: admin | ||
Password: ' . $password; | ||
|
||
// Post comment to GitHub. | ||
$ch = curl_init('https://api.github.com/repos/' . getenv('TUGBOAT_GITHUB_OWNER') . '/' . getenv('TUGBOAT_GITHUB_REPO') . '/issues/' . getenv('TUGBOAT_GITHUB_PR') . '/comments'); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | ||
'Authorization: token ' . getenv('BACKDROP_GITHUB_TOKEN'), | ||
'Content-Type: application/json', | ||
'Accept: application/vnd.github.v3+json', | ||
'User-Agent: Backdrop CMS', | ||
)); | ||
curl_setopt($ch, CURLOPT_POST, TRUE); | ||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array('body' => $comment))); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | ||
curl_exec($ch); | ||
curl_close($ch); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
// Database. | ||
$database = 'mysql://tugboat:tugboat@mariadb/tugboat'; | ||
$database_charset = 'utf8mb4'; | ||
|
||
// Config. | ||
$config_directories['active'] = 'files/config/active'; | ||
$config_directories['staging'] = 'files/config/staging'; | ||
|
||
// Trusted hosts. | ||
$settings['trusted_host_patterns'] = array('^.+\.tugboat\.qa$'); | ||
|
||
// Miscellaneous. |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.