Skip to content

Commit 7ab2348

Browse files
Move domain, upgrade symfony
1 parent 766a110 commit 7ab2348

22 files changed

+1064
-1088
lines changed

.env

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# In all environments, the following files are loaded if they exist,
2+
# the latter taking precedence over the former:
3+
#
4+
# * .env contains default values for the environment variables needed by the app
5+
# * .env.local uncommitted file with local overrides
6+
# * .env.$APP_ENV committed environment-specific defaults
7+
# * .env.$APP_ENV.local uncommitted environment-specific overrides
8+
#
9+
# Real environment variables win over .env files.
10+
#
11+
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
12+
# https://symfony.com/doc/current/configuration/secrets.html
13+
#
14+
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
15+
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
16+
17+
###> symfony/framework-bundle ###
18+
APP_ENV=dev
19+
APP_SECRET=27ece57ba8aa437809ed5e6ef26e4636
20+
###< symfony/framework-bundle ###

.github/workflows/ci-prod.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
on:
2+
workflow_dispatch:
3+
push:
4+
branches:
5+
- main
6+
name: CI:prod
7+
jobs:
8+
9+
deploy-test:
10+
name: Deploy to hatt.style
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: '8.2'
17+
- name: Get composer cache directory
18+
id: composer-cache
19+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
20+
- name: Cache dependencies
21+
uses: actions/cache@v1
22+
with:
23+
path: ${{ steps.composer-cache.outputs.dir }}
24+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
25+
restore-keys: ${{ runner.os }}-composer-
26+
- name: Install dependencies
27+
run: composer install --no-dev --prefer-dist
28+
# - name: Get npm cache directory
29+
# id: npm-cache
30+
# run: |
31+
# echo "::set-output name=dir::$(npm config get cache)"
32+
# - uses: actions/cache@v1
33+
# with:
34+
# path: ${{ steps.npm-cache.outputs.dir }}
35+
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
36+
# restore-keys: |
37+
# ${{ runner.os }}-node-
38+
# - name: Install JavaScript dependencies
39+
# run: npm install
40+
- name: Deploy over FTPS
41+
env:
42+
USERNAME: ${{ secrets.DEPLOY_USERNAME }}
43+
PASSWORD: ${{ secrets.DEPLOY_PASSWORD }}
44+
run: php ./Deploy.php --target=cyon --environment=prod --username="$USERNAME"

.github/workflows/ci-test.yml .github/workflows/ci-staging.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ name: CI:test
66
jobs:
77

88
deploy-test:
9-
name: Deploy to flatastic.hatt.style
9+
name: Deploy to hatt.style
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
1313
- uses: shivammathur/setup-php@v2
1414
with:
15-
php-version: '8.0'
15+
php-version: '8.2'
1616
- name: Get composer cache directory
1717
id: composer-cache
1818
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
@@ -40,4 +40,4 @@ jobs:
4040
env:
4141
USERNAME: ${{ secrets.DEPLOY_USERNAME }}
4242
PASSWORD: ${{ secrets.DEPLOY_PASSWORD }}
43-
run: php ./Deploy.php --environment=prod --username="$USERNAME"
43+
run: php ./Deploy.php --target=cyon --environment=prod --username="$USERNAME"

Deploy.php

+40-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
<?php
22

3+
use League\Flysystem\Filesystem;
4+
use League\Flysystem\Ftp\FtpAdapter;
5+
use League\Flysystem\Ftp\FtpConnectionOptions;
6+
use Monolog\Handler\ErrorLogHandler;
7+
use Monolog\Logger;
38
use PhpDeploy\AbstractDefaultDeploy;
49

510
require_once __DIR__.'/vendor/autoload.php';
611

712
class Deploy extends AbstractDefaultDeploy {
8-
protected function populateFolder() {
13+
protected function populateFolder(): void {
914
$fs = new Symfony\Component\Filesystem\Filesystem();
1015

1116
$build_folder_path = $this->getLocalBuildFolderPath();
1217
$fs->mirror(__DIR__, $build_folder_path);
1318
}
1419

15-
protected function getFlysystemFilesystem() {
16-
$options = League\Flysystem\Ftp\FtpConnectionOptions::fromArray([
20+
protected function getFlysystemFilesystem(): Filesystem {
21+
$options = FtpConnectionOptions::fromArray([
1722
'host' => 's007.cyon.net', // required
1823
'root' => '/', // required
1924
'username' => $this->username, // required
@@ -22,30 +27,47 @@ protected function getFlysystemFilesystem() {
2227
'ssl' => true,
2328
'timeout' => 90,
2429
]);
25-
$adapter = new League\Flysystem\Ftp\FtpAdapter($options);
26-
return new League\Flysystem\Filesystem($adapter);
30+
$adapter = new FtpAdapter($options);
31+
return new Filesystem($adapter);
2732
}
2833

29-
public function getRemotePublicPath() {
30-
return 'public';
34+
public function getRemotePublicPath(): string {
35+
return 'public_html/deploy.hatt.style';
3136
}
3237

33-
public function getRemotePublicUrl() {
34-
return "https://flatastic.hatt.style";
38+
public function getRemotePublicUrl(): string {
39+
return "https://deploy.hatt.style";
3540
}
3641

37-
public function getRemotePrivatePath() {
38-
return 'private';
42+
public function getRemotePrivatePath(): string {
43+
return 'private_files';
3944
}
4045

41-
public function install($public_path) {
46+
/** @return array<string, string> */
47+
public function install(string $public_path): array {
48+
$getPublicPathForSubdomain = function (string $subdomain) use ($public_path): string {
49+
return str_replace($this->getRemotePublicPath(), "public_html/{$subdomain}", $public_path);
50+
};
51+
52+
// hatt.style
53+
$base_public = $getPublicPathForSubdomain('hatt.style');
54+
$this->installForSubdomain($base_public);
55+
56+
// flatastic.hatt.style
57+
$flatastic_public = $getPublicPathForSubdomain('flatastic.hatt.style');
58+
$this->installForSubdomain($flatastic_public);
59+
60+
return [];
61+
}
62+
63+
protected function installForSubdomain(string $public_path): void {
4264
$fs = new Symfony\Component\Filesystem\Filesystem();
43-
$fs->mirror(__DIR__.'/public', $public_path, null, ['delete' => true]);
65+
$fs->copy(__DIR__.'/public/.htaccess', "{$public_path}/.htaccess", true);
4466
$index_path = "{$public_path}/index.php";
45-
$index_contents = file_get_contents($index_path);
67+
$index_contents = file_get_contents(__DIR__.'/public/index.php');
4668
$updated_index_contents = str_replace(
4769
"require_once dirname(__DIR__).'/vendor/autoload_runtime.php';",
48-
"require_once dirname(__DIR__).'/private/deploy/live/vendor/autoload_runtime.php';",
70+
"require_once __DIR__.'/../../private_files/deploy/live/vendor/autoload_runtime.php';",
4971
$index_contents,
5072
);
5173
unlink($index_path);
@@ -55,5 +77,8 @@ public function install($public_path) {
5577

5678
if (isset($_SERVER['argv'])) {
5779
$deploy = new Deploy();
80+
$logger = new Logger('deploy');
81+
$logger->pushHandler(new ErrorLogHandler());
82+
$deploy->setLogger($logger);
5883
$deploy->cli();
5984
}

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# flatastic.hatt.style
2-
API to use flatastic app with home assistant
1+
# hatt.style
2+
3+
All my hobby projects

bin/console

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
use App\Kernel;
55
use Symfony\Bundle\FrameworkBundle\Console\Application;
66

7+
if (!is_dir(dirname(__DIR__).'/vendor')) {
8+
throw new LogicException('Dependencies are missing. Try running "composer install".');
9+
}
10+
711
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
812
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
913
}

composer.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "allestuetsmerweh/flatastic.hatt.style",
2+
"name": "allestuetsmerweh/hatt.style",
33
"type": "project",
44
"license": "MIT",
55
"authors": [
@@ -11,21 +11,21 @@
1111
"minimum-stability": "stable",
1212
"prefer-stable": true,
1313
"require": {
14-
"php": ">=8.0.2",
14+
"php": ">=8.2",
1515
"ext-ctype": "*",
1616
"ext-iconv": "*",
17-
"allestuetsmerweh/php-deploy": "^1.0",
18-
"league/flysystem": "^2.3",
19-
"league/flysystem-ftp": "^2.3",
17+
"allestuetsmerweh/php-deploy": "^2.7",
18+
"league/flysystem": "^3.29",
19+
"league/flysystem-ftp": "^3.29",
2020
"symfony/apache-pack": "^1.0",
21-
"symfony/console": "6.0.*",
22-
"symfony/dotenv": "6.0.*",
21+
"symfony/console": "7.1.*",
22+
"symfony/dotenv": "7.1.*",
2323
"symfony/flex": "^2",
24-
"symfony/framework-bundle": "6.0.*",
25-
"symfony/http-client": "6.0.*",
24+
"symfony/framework-bundle": "7.1.*",
25+
"symfony/http-client": "7.1.*",
2626
"symfony/monolog-bundle": "^3.8",
27-
"symfony/runtime": "6.0.*",
28-
"symfony/yaml": "6.0.*"
27+
"symfony/runtime": "7.1.*",
28+
"symfony/yaml": "7.1.*"
2929
},
3030
"config": {
3131
"allow-plugins": {
@@ -75,7 +75,7 @@
7575
"extra": {
7676
"symfony": {
7777
"allow-contrib": false,
78-
"require": "6.0.*"
78+
"require": "7.1.*"
7979
}
8080
}
8181
}

0 commit comments

Comments
 (0)