Skip to content

Commit

Permalink
Clean up DEPLOY_CDN usage and target just docker deployment of a blaz…
Browse files Browse the repository at this point in the history
…or app.
  • Loading branch information
Layoric committed Oct 2, 2023
1 parent 00bd934 commit df96944
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 99 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,44 +72,6 @@ jobs:
context: .
push: true
tags: ghcr.io/${{ env.image_repository_name }}:${{ env.TAG_NAME }}
build-args: |
DEPLOY_API=${{ secrets.DEPLOY_API }}
DEPLOY_CDN=${{ secrets.DEPLOY_CDN }}
- name: Create env.deploy_cdn
run: |
echo "deploy_cdn=${{ secrets.DEPLOY_CDN }}" >> $GITHUB_ENV
- name: Run CI Prebuild Script
env:
deploy_api: ${{ secrets.DEPLOY_API }}
deploy_cdn: ${{ secrets.DEPLOY_CDN }}
run: |
if [ -e ./.deploy/ci.prebuild.sh ]
then
chmod +x ./.deploy/ci.prebuild.sh
./.deploy/ci.prebuild.sh
else
echo "Skipping CI prebuild"
fi
# Publish .NET Project, generate static content in wwwroot
- name: Publish dotnet project
working-directory: ./Gallery.Unified
run: |
dotnet publish -c Release /p:DEPLOY_API=${{ secrets.DEPLOY_API }} /p:DEPLOY_CDN=${{ secrets.DEPLOY_CDN }}
# Deploy UI to GitHub Pages
- name: Deploy to GitHub Pages
env:
deploy_cdn: ${{ secrets.DEPLOY_CDN }}
if: ${{ env.deploy_cdn != '' }}
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./Gallery.Unified/bin/Release/net8.0/publish/wwwroot
user_name: 'GitHub Action'
user_email: '[email protected]'

deploy_via_ssh:
needs: push_to_registry
Expand Down Expand Up @@ -143,7 +105,6 @@ jobs:
echo "# Autogenerated .env file" > .deploy/.env
echo "HOST_DOMAIN=${{ secrets.DEPLOY_API }}" >> .deploy/.env
echo "DEPLOY_CDN=${{ secrets.DEPLOY_CDN }}" >> .deploy/.env
echo "LETSENCRYPT_EMAIL=${{ secrets.LETSENCRYPT_EMAIL }}" >> .deploy/.env
echo "APP_NAME=${{ github.event.repository.name }}" >> .deploy/.env
echo "IMAGE_REPO=${{ env.image_repository_name }}" >> .deploy/.env
Expand Down
3 changes: 1 addition & 2 deletions Gallery.Unified/Configure.AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ public override void Configure(Container container)
"https://docs.servicestack.net",
"https://jamstacks.net",
"https://razor-ssg.web-templates.io",
"https://razor-press.web-templates.io",
"https://" + Environment.GetEnvironmentVariable("DEPLOY_CDN")
"https://razor-press.web-templates.io"
}, allowCredentials: true));


Expand Down
40 changes: 1 addition & 39 deletions Gallery.Unified/Gallery.Unified.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,43 +28,5 @@
<ItemGroup>
<ProjectReference Include="..\Gallery.Unified.Client\Gallery.Unified.Client.csproj" />
</ItemGroup>

<ItemGroup>
<_ContentIncludedByDefault Remove="wwwroot\css\app.css" />
<_ContentIncludedByDefault Remove="wwwroot\css\markdown.css" />
<_ContentIncludedByDefault Remove="wwwroot\css\typography.css" />
<_ContentIncludedByDefault Remove="wwwroot\js\highlight.cshtml-razor.min.js" />
<_ContentIncludedByDefault Remove="wwwroot\js\highlight.min.js" />
<_ContentIncludedByDefault Remove="wwwroot\js\servicestack-blazor.js" />
<_ContentIncludedByDefault Remove="wwwroot\tailwind\ServiceStack.Blazor.html" />
</ItemGroup>

<PropertyGroup>
<WwwRoot>$(MSBuildProjectDirectory)/wwwroot</WwwRoot>
<WwwRootPublish>$(MSBuildProjectDirectory)/$(PublishUrl)wwwroot</WwwRootPublish>
</PropertyGroup>

<!-- Populated in release.yml with GitHub Actions secrets -->
<Target Name="DeployApi" AfterTargets="Build" Condition="$(DEPLOY_API) != ''">
<Exec Command="echo DEPLOY_API=$(DEPLOY_API)" />

<!-- Update Production settings with DEPLOY_API Blazor UI should use -->
<WriteLinesToFile File="$(WwwRoot)/appsettings.Production.json" Lines="$([System.IO.File]::ReadAllText($(WwwRoot)/appsettings.Production.json).Replace('{DEPLOY_API}',$(DEPLOY_API)))" Overwrite="true" Encoding="UTF-8" />

<!-- define /api proxy routes (supported by Cloudflare or Netlify CDNs) -->
<WriteLinesToFile File="$(WwwRoot)/_redirects" Lines="$([System.IO.File]::ReadAllText($(WwwRoot)/_redirects).Replace('{DEPLOY_API}',$(DEPLOY_API)))" Overwrite="true" Encoding="UTF-8" />
</Target>
<Target Name="DeployCdn" AfterTargets="Build" Condition="$(DEPLOY_CDN) != ''">
<Exec Command="echo DEPLOY_CDN=$(DEPLOY_CDN)" />

<!-- Define custom domain name that CDN should use -->
<Exec Condition="$(DEPLOY_CDN) != ''" Command="echo $(DEPLOY_CDN) &gt; $(WwwRoot)/CNAME" />
</Target>
<!-- -->
<!-- <Target Name="IndexFallback" AfterTargets="AfterPublish" Condition="$(DEPLOY_CDN) != ''">-->
<!-- <Exec Command="ls -la $(WwwRootPublish)" />-->
<!-- &lt;!&ndash; 404.html SPA fallback (supported by GitHub Pages, Cloudflare & Netlify CDNs) &ndash;&gt;-->
<!-- <Copy SourceFiles="$(WwwRootPublish)/index.html" DestinationFiles="$(WwwRootPublish)/404.html" />-->
<!-- </Target>-->
<!-- -->

</Project>
3 changes: 0 additions & 3 deletions Gallery.Unified/Pages/Home.razor

This file was deleted.

10 changes: 1 addition & 9 deletions Gallery.Unified/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,10 @@
}

app.UseStaticFiles();
app.UseBlazorFrameworkFiles();

app.UseServiceStack(new AppHost());

// BlazorConfig.Set(new BlazorConfig
// {
// IsWasm = true,
// Services = app.Services,
// FallbackAssetsBasePath = baseUrl,
// EnableLogging = true,
// EnableVerboseLogging = app.Environment.IsDevelopment(),
// });

app.MapRazorComponents<App>()
.AddServerRenderMode()
.AddWebAssemblyRenderMode();
Expand Down
Empty file removed Gallery.Unified/wwwroot/.nojekyll
Empty file.
1 change: 0 additions & 1 deletion Gallery.Unified/wwwroot/CNAME

This file was deleted.

3 changes: 0 additions & 3 deletions Gallery.Unified/wwwroot/_headers

This file was deleted.

1 change: 0 additions & 1 deletion Gallery.Unified/wwwroot/_redirects

This file was deleted.

4 changes: 2 additions & 2 deletions Gallery.Unified/wwwroot/appsettings.Production.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"ApiBaseUrl": "https://{DEPLOY_API}"
{
"ApiBaseUrl": "https://localhost"
}

0 comments on commit df96944

Please sign in to comment.