-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
OSOE-514: Deployment action with GitHub Actions and better configuration
- Loading branch information
Showing
12 changed files
with
468 additions
and
105 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Deploy Media Theme | ||
description: Deploys an Orchard Core Media Theme to an Orchard site via Remote Deployment. | ||
|
||
inputs: | ||
theme-path: | ||
required: false | ||
default: "." | ||
description: Path to the theme project. | ||
base-theme-id: | ||
required: false | ||
description: ID of the base theme of the theme project, if any. | ||
clear-media-folder: | ||
required: false | ||
default: "true" | ||
description: When set to "true", will clear the Media folder of the Media Theme before deployment. | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install Lombiq.Hosting.MediaTheme.Deployer | ||
shell: pwsh | ||
run: | | ||
dotnet tool install --global Lombiq.Hosting.MediaTheme.Deployer --version 2.0.2-alpha.0.osoe-514 | ||
- name: Deploy Media Theme | ||
shell: pwsh | ||
run: | | ||
# Putting --base-id as last, so if it's empty, then the other parameters will still be parsed correctly. | ||
$switches = @( | ||
'--path', '${{ inputs.theme-path }}' | ||
'--clear', '${{ inputs.clear-media-folder }}' | ||
'--deployment-path', '${{ inputs.theme-path }}/Deployment' | ||
'--remote-deployment-url', '${{ env.URL }}' | ||
'--remote-deployment-client-name', '${{ env.CLIENT_NAME }}' | ||
'--remote-deployment-client-api-key', '${{ env.CLIENT_API_KEY }}' | ||
'--base-id', '${{ inputs.base-theme-id }}' | ||
) | ||
media-theme-deploy @switches | ||
if ($LastExitCode -ne 0) | ||
{ | ||
Write-Error "Deployment failed, see the errors above." | ||
} |
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,54 @@ | ||
name: Deploy Media Theme | ||
|
||
on: | ||
workflow_call: | ||
secrets: | ||
CHECKOUT_TOKEN: | ||
required: false | ||
description: > | ||
The GitHub token to authenticate checkout. Pass in a GitHub personal access token if authenticated submodules | ||
are used. | ||
URL: | ||
required: true | ||
description: The URL to use for Remote Deployment, as indicated on the Orchard Core admin. | ||
CLIENT_NAME: | ||
required: true | ||
description: The "Client Name" part of the Remote Deployment client's credentials. | ||
CLIENT_API_KEY: | ||
required: true | ||
description: The "Client API Key" part of the Remote Deployment client's credentials. | ||
inputs: | ||
theme-path: | ||
required: false | ||
type: string | ||
default: "." | ||
description: Path to the theme project. | ||
base-theme-id: | ||
required: false | ||
type: string | ||
description: ID of the base theme of the theme project, if any. | ||
clear-media-folder: | ||
required: false | ||
type: string | ||
default: "true" | ||
description: When set to "true", will clear the Media folder of the Media Theme before deployment. | ||
|
||
jobs: | ||
deploy-media-theme: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev | ||
with: | ||
token: ${{ secrets.CHECKOUT_TOKEN }} | ||
|
||
- name: Deploy Media Theme | ||
uses: Lombiq/Hosting-Media-Theme/.github/actions/deploy-media-theme@dev | ||
env: | ||
URL: ${{ secrets.URL }} | ||
CLIENT_NAME: ${{ secrets.CLIENT_NAME }} | ||
CLIENT_API_KEY: ${{ secrets.CLIENT_API_KEY }} | ||
with: | ||
theme-path: ${{ inputs.theme-path }} | ||
base-theme-id: ${{ inputs.base-theme-id }} | ||
clear-media-folder: ${{ inputs.clear-media-folder }} |
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
57 changes: 57 additions & 0 deletions
57
Lombiq.Hosting.MediaTheme.Bridge/Services/FileVersionProviderDecorator.cs
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,57 @@ | ||
using Lombiq.Hosting.MediaTheme.Bridge.Constants; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc.ViewFeatures; | ||
using Microsoft.Extensions.Options; | ||
using OrchardCore.FileStorage; | ||
using OrchardCore.Media; | ||
using OrchardCore.Mvc; | ||
using System; | ||
|
||
namespace Lombiq.Hosting.MediaTheme.Bridge.Services; | ||
|
||
/// <summary> | ||
/// Service to add a cache busting version key to the URL of static resources references from Media Theme, like it | ||
/// happens for standard resources. | ||
/// </summary> | ||
/// <remarks> | ||
/// <para> | ||
/// The default <see cref="IFileVersionProvider"/>, <see cref="ShellFileVersionProvider"/>, works just fine, but we need | ||
/// to translate /mediatheme URLs. | ||
/// </para> | ||
/// </remarks> | ||
internal class FileVersionProviderDecorator : IFileVersionProvider | ||
{ | ||
private readonly IFileVersionProvider _decorated; | ||
private readonly IMediaFileStore _mediaFileStore; | ||
private readonly IOptions<MediaOptions> _mediaOption; | ||
|
||
public FileVersionProviderDecorator( | ||
IFileVersionProvider decorated, | ||
IMediaFileStore mediaFileStore, | ||
IOptions<MediaOptions> mediaOptions) | ||
{ | ||
_decorated = decorated; | ||
_mediaFileStore = mediaFileStore; | ||
_mediaOption = mediaOptions; | ||
} | ||
|
||
public string AddFileVersionToPath(PathString requestPathBase, string path) | ||
{ | ||
var isMediaThemePath = path.StartsWithOrdinalIgnoreCase(Routes.MediaThemeAssets) || | ||
path.ContainsOrdinalIgnoreCase(Routes.MediaThemeAssets + "/"); | ||
|
||
if (isMediaThemePath) | ||
{ | ||
var assetsSubPath = _mediaFileStore.Combine( | ||
_mediaOption.Value.AssetsRequestPath, Paths.MediaThemeRootFolder, Paths.MediaThemeAssetsFolder); | ||
path = path.Replace(Routes.MediaThemeAssets, assetsSubPath); | ||
} | ||
|
||
// Note that this will work all the time for local files. When a remote storage implementation is used to store | ||
// Media files though (like Azure Blob Storage) then Media Cache will mirror the files locally. Since this only | ||
// happens on the first request to the file, until then in the HTML output you'll see a URL without the cache | ||
// busting parameter. | ||
// This isn't an issue for real-life scenarios, just be mindful during development. | ||
return _decorated.AddFileVersionToPath(requestPathBase, path); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
[assembly: SuppressMessage( | ||
"Globalization", | ||
"CA1303:Do not pass literals as localized parameters", | ||
Justification = "It's a developer console application, it doesn't need localization.", | ||
Scope = "module")] |
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.