Merge branch '29-profile-page' of http://git.fufle.net/Community/CureNet into 29-profile-page
This commit is contained in:
commit
c2a2a83fb5
|
@ -74,8 +74,8 @@ pipeline {
|
|||
stage('Backend') {
|
||||
steps {
|
||||
dir(path: 'src/backend') {
|
||||
sh "APP_SECRET=`php8.0 -r 'echo md5(\"branch=${BRANCH_NAME};\");'` && sed -i \"s/APP_SECRET=.*/APP_SECRET=${APP_SECRET}/g\" .env.test"
|
||||
sh "sed -i \"s+DATABASE_URL=.*+DATABASE_URL=${DatabaseUrlTesting}+g\" .env.test"
|
||||
sh "echo `php8.0 -r 'echo md5(\"branch=${BRANCH_NAME};\");'` | php8.0 ../../tools/putenv/putenv.php .env.test APP_SECRET"
|
||||
sh "php8.0 ../../tools/putenv/putenv.php .env.test DATABASE_URL \"${DatabaseUrlTesting}\""
|
||||
sh 'php8.0 /usr/local/bin/composer dump-env test'
|
||||
sh 'php8.0 bin/console doctrine:schema:update --force';
|
||||
}
|
||||
|
@ -123,8 +123,8 @@ pipeline {
|
|||
stage('Backend') {
|
||||
steps {
|
||||
dir(path: 'src/backend') {
|
||||
sh "APP_SECRET=`php8.0 -r 'echo md5(\"branch=${BRANCH_NAME};\");'` && sed -i \"s/APP_SECRET=.*/APP_SECRET=${APP_SECRET}/g\" .env"
|
||||
sh "sed -i \"s+DATABASE_URL=.*+DATABASE_URL=${DatabaseUrl}+g\" .env"
|
||||
sh "echo `php8.0 -r 'echo md5(\"branch=${BRANCH_NAME};\");'` | php8.0 ../../tools/putenv/putenv.php .env APP_SECRET"
|
||||
sh "php8.0 ../../tools/putenv/putenv.php .env DATABASE_URL \"${DatabaseUrl}\""
|
||||
sh 'php8.0 /usr/local/bin/composer dump-env prod'
|
||||
}
|
||||
|
||||
|
@ -189,6 +189,8 @@ pipeline {
|
|||
sh 'scp -r ./* web@fufle.net:${ProjectPath}/backend/'
|
||||
sh 'scp -r ./.env web@fufle.net:${ProjectPath}/backend/.env'
|
||||
sh 'ssh web@fufle.net chmod 777 ${ProjectPath}/backend/var -R'
|
||||
sh 'ssh web@fufle.net "cd ${ProjectPath}/backend; php8.0 bin/console doctrine:schema:update --force"'
|
||||
sh 'ssh web@fufle.net "cd ${ProjectPath}/backend; php8.0 bin/console lexik:jwt:generate-keypair --skip-if-exists"'
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
name=value
|
||||
name2="value 2"
|
||||
#name3=value3
|
||||
name4 = value4
|
||||
name5 = "value 5"
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
namespace Tools;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PutEnv {
|
||||
|
||||
private string $file;
|
||||
private string $key;
|
||||
private string $value;
|
||||
private array $content;
|
||||
|
||||
public function __construct() {
|
||||
$argv = $_SERVER['argv'];
|
||||
$argc = sizeof($argv);
|
||||
switch($argc) {
|
||||
case 4:
|
||||
$this->file = $argv[1];
|
||||
$this->key = $argv[2];
|
||||
$this->value = $argv[3];
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$this->file = $argv[1];
|
||||
$this->key = $argv[2];
|
||||
$this->value = fgets(STDIN);
|
||||
break;
|
||||
|
||||
default:
|
||||
echo "usage:
|
||||
php8.0 putenv.php filename key value
|
||||
echo value | php8.0 putenv filename key";
|
||||
throw new Exception("invalid params");
|
||||
}
|
||||
if (!file_exists($this->file)) {
|
||||
throw new Exception('File not found');
|
||||
}
|
||||
$changed = 0;
|
||||
$lineWasEmpty = false;
|
||||
$key = $this->key;
|
||||
$value = $this->value;
|
||||
if (strpos($value, ' ') !== false) {
|
||||
$value = '"' . addslashes($value) . '"';
|
||||
}
|
||||
$this->content = file($this->file);
|
||||
foreach ($this->content as $l => $line) {
|
||||
$this->content[$l] = $line = trim($line);
|
||||
if (strlen($line) < 1) {
|
||||
if ($lineWasEmpty) {
|
||||
$this->content[$l] = null;
|
||||
} else {
|
||||
$lineWasEmpty = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
$lineWasEmpty = false;
|
||||
if (!str_starts_with($line, $this->key)) {
|
||||
continue;
|
||||
}
|
||||
$next = trim(substr($line, strlen($this->key)));
|
||||
if (strlen($next) === 0 || $next[0] !== '=') {
|
||||
continue;
|
||||
}
|
||||
$this->content[$l] = $key . '=' . $value . \PHP_EOL;
|
||||
$changed++;
|
||||
}
|
||||
if ($changed === 0) {
|
||||
$this->content[] = $key . '=' . $value;
|
||||
} else if ($changed > 1) {
|
||||
echo "Key $key changed $changed times\n";
|
||||
}
|
||||
$content = $this->content;
|
||||
$this->content = [];
|
||||
foreach ($content as $line) {
|
||||
if ($line !== null) {
|
||||
$this->content[] = $line;
|
||||
}
|
||||
}
|
||||
$content = implode(PHP_EOL, $this->content);
|
||||
file_put_contents($this->file, $content);
|
||||
}
|
||||
}
|
||||
|
||||
new PutEnv();
|
Loading…
Reference in New Issue