Skip to content

Commit

Permalink
Merge pull request #494 from leepeuker/add-actions-to-deploy-openapi-…
Browse files Browse the repository at this point in the history
…changes

Add actions workflow to deploy openapi changes
  • Loading branch information
leepeuker authored Sep 7, 2023
2 parents 1821f97 + 33da09b commit 405f28e
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy mkdocs
name: Deploy mkdocs to https://docs.movary.org

on:
release:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/deploy-openapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy openapi.json to https://api.movary.org

on:
release:
types: [published]
paths:
- docs/openapi.json

jobs:


build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: copy files
uses: appleboy/scp-action@v0.1.4
with:
host: ${{ secrets.DOCS_SSH_HOST }}
username: ${{ secrets.DOCS_SSH_USER }}
key: ${{ secrets.DOCS_SSH_KEY }}
source: "docs/openapi.json"
target: ${{ secrets.API_DEPLOYMENT_DIRECTORY }}
strip_components: 1
- uses: actions/checkout@v3
- name: update openapi application version
uses: appleboy/ssh-action@v0.1.10
with:
host: ${{ secrets.DOCS_SSH_HOST }}
username: ${{ secrets.DOCS_SSH_USER }}
key: ${{ secrets.DOCS_SSH_KEY }}
script: >
sed -i 's/"version": ""/"version": "${{ github.ref_name }}"/g' ${{ secrets.API_DEPLOYMENT_DIRECTORY }}/openapi.json
1 change: 0 additions & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
\Movary\HttpController\Web\CreateUserController::class => DI\factory([Factory::class, 'createCreateUserController']),
\Movary\HttpController\Web\JobController::class => DI\factory([Factory::class, 'createJobController']),
\Movary\HttpController\Web\LandingPageController::class => DI\factory([Factory::class, 'createLandingPageController']),
\Movary\HttpController\Web\SettingsController::class => DI\factory([Factory::class, 'createSettingsController']),
\Movary\HttpController\Web\Middleware\ServerHasRegistrationEnabled::class => DI\factory([Factory::class, 'createMiddlewareServerHasRegistrationEnabled']),
\Movary\ValueObject\Http\Request::class => DI\factory([Factory::class, 'createCurrentHttpRequest']),
\Movary\Command\CreatePublicStorageLink::class => DI\factory([Factory::class, 'createCreatePublicStorageLink']),
Expand Down
6 changes: 1 addition & 5 deletions docs/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
"title": "Movary",
"version": ""
},
"servers": [
{
"url": "\/api"
}
],
"servers": [],
"paths": {
"\/users\/{username}\/history": {
"get": {
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Jellyfin/JellyfinClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private function convertException(\Exception $e, Url $url) : \Exception
private function generateHeaders(?JellyfinAccessToken $jellyfinAccessToken = null) : array
{
$appName = $this->serverSettings->getJellyfinAppName();
$appVersion = $this->serverSettings->getApplicationVersion() ?? 'dev';
$appVersion = $this->serverSettings->getApplicationVersion();
$deviceId = $this->serverSettings->requireJellyfinDeviceId();

$authorizationString = 'MediaBrowser Client ="' . $appName . '", Device ="' . php_uname('s') . '", Version="' . $appVersion . '", DeviceId="' . $deviceId . '"';
Expand Down
41 changes: 0 additions & 41 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Movary\Api\Github\GithubApi;
use Movary\Api\Jellyfin\JellyfinApi;
use Movary\Api\Plex\PlexApi;
use Movary\Api\Tmdb;
use Movary\Api\Tmdb\TmdbUrlGenerator;
use Movary\Api\Trakt\Cache\User\Movie\Watched;
Expand All @@ -22,27 +19,20 @@
use Movary\Domain\Movie\Watchlist\MovieWatchlistApi;
use Movary\Domain\User;
use Movary\Domain\User\Service\Authentication;
use Movary\Domain\User\Service\TwoFactorAuthenticationApi;
use Movary\Domain\User\UserApi;
use Movary\HttpController\Api\OpenApiController;
use Movary\HttpController\Middleware;
use Movary\HttpController\Web\CreateUserController;
use Movary\HttpController\Web\JobController;
use Movary\HttpController\Web\LandingPageController;
use Movary\HttpController\Web\SettingsController;
use Movary\JobQueue\JobQueueApi;
use Movary\JobQueue\JobQueueScheduler;
use Movary\Service\Dashboard\DashboardFactory;
use Movary\Service\Email\EmailService;
use Movary\Service\Export\ExportService;
use Movary\Service\Export\ExportWriter;
use Movary\Service\ImageCacheService;
use Movary\Service\JobProcessor;
use Movary\Service\Letterboxd\LetterboxdExporter;
use Movary\Service\Letterboxd\Service\LetterboxdCsvValidator;
use Movary\Service\ServerSettings;
use Movary\Service\UrlGenerator;
use Movary\Service\WebhookUrlBuilder;
use Movary\Util\File;
use Movary\Util\SessionWrapper;
use Movary\ValueObject\Config;
Expand All @@ -67,8 +57,6 @@ class Factory

private const DEFAULT_LOG_LEVEL = LogLevel::WARNING;

private const DEFAULT_APPLICATION_VERSION = 'unknown';

private const DEFAULT_TMDB_IMAGE_CACHING = false;

private const DEFAULT_LOG_ENABLE_STACKTRACE = false;
Expand Down Expand Up @@ -266,30 +254,6 @@ public static function createOpenApiController(ContainerInterface $container) :
);
}

public static function createSettingsController(ContainerInterface $container, Config $config) : SettingsController
{
return new SettingsController(
$container->get(Twig\Environment::class),
$container->get(Authentication::class),
$container->get(TwoFactorAuthenticationApi::class),
$container->get(UserApi::class),
$container->get(MovieApi::class),
$container->get(GithubApi::class),
$container->get(PlexApi::class),
$container->get(SessionWrapper::class),
$container->get(LetterboxdExporter::class),
$container->get(TraktApi::class),
$container->get(JellyfinApi::class),
$container->get(ServerSettings::class),
$container->get(WebhookUrlBuilder::class),
$container->get(JobQueueApi::class),
$container->get(DashboardFactory::class),
$container->get(EmailService::class),
$container->get(Tmdb\Cache\TmdbIsoCountryCache::class),
self::getApplicationVersion($config),
);
}

public static function createTmdbApiClient(ContainerInterface $container) : Tmdb\TmdbClient
{
return new Tmdb\TmdbClient(
Expand Down Expand Up @@ -417,11 +381,6 @@ private static function createLoggerStreamHandlerStdout(ContainerInterface $cont
return $streamHandler;
}

private static function getApplicationVersion(Config $config) : string
{
return $config->getAsString('APPLICATION_VERSION', self::DEFAULT_APPLICATION_VERSION);
}

private static function getLogLevel(Config $config) : string
{
return $config->getAsString('LOG_LEVEL', self::DEFAULT_LOG_LEVEL);
Expand Down
1 change: 1 addition & 0 deletions src/HttpController/Api/OpenApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function getSchema() : Response

$openapiData['info']['version'] = $this->serverSettings->getApplicationVersion();

$openapiData['servers'][0]['url'] = '/api';
$applicationUrl = $this->serverSettings->getApplicationUrl();
if ($applicationUrl !== null) {
$openapiData['servers'][0]['url'] = trim($applicationUrl, '/') . '/api';
Expand Down
3 changes: 1 addition & 2 deletions src/HttpController/Web/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public function __construct(
private readonly DashboardFactory $dashboardFactory,
private readonly EmailService $emailService,
private readonly TmdbIsoCountryCache $countryCache,
private readonly string $currentApplicationVersion,
) {
}

Expand Down Expand Up @@ -152,7 +151,7 @@ public function renderAppPage() : Response
return Response::create(
StatusCode::createOk(),
$this->twig->render('page/settings-app.html.twig', [
'currentApplicationVersion' => $this->currentApplicationVersion,
'currentApplicationVersion' => $this->serverSettings->getApplicationVersion(),
'latestRelease' => $this->githubApi->fetchLatestMovaryRelease(),
'timeZone' => date_default_timezone_get(),
]),
Expand Down
4 changes: 2 additions & 2 deletions src/Service/ServerSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public function getApplicationUrl() : ?string
return $this->getByKey(self::APPLICATION_URL);
}

public function getApplicationVersion() : ?string
public function getApplicationVersion() : string
{
return $this->getByKey(self::APPLICATION_VERSION);
return $this->getByKey(self::APPLICATION_VERSION) ?? 'unknown';
}

public function getFromAddress() : ?string
Expand Down

0 comments on commit 405f28e

Please sign in to comment.