Skip to content

Commit

Permalink
Merge pull request #7 from ThomasAunvik/upgrade
Browse files Browse the repository at this point in the history
Upgrade
  • Loading branch information
ThomasAunvik authored Apr 27, 2024
2 parents b0b36c7 + 7dde6ec commit 12c776b
Show file tree
Hide file tree
Showing 184 changed files with 7,730 additions and 9,946 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/azure-static-web-apps-yellow-grass-0d78f5703.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Azure Static Web Apps CI/CD

on:
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- master

jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v4
with:
submodules: true
lfs: false
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_YELLOW_GRASS_0D78F5703 }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "Web/Client" # App source code path
api_location: "Web/Client/lib/api/functions/" # Api source code path - optional
output_location: "" # Built app content directory - optional
###### End of Repository/Build Configurations ######

close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_YELLOW_GRASS_0D78F5703 }}
action: "close"
app_location: "Web/Client"
121 changes: 88 additions & 33 deletions .github/workflows/master_ffxvi-clive-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,80 +11,106 @@ on:

jobs:
# BUILDS
buildbot:
build-bot:
name: Build Bot
runs-on: ubuntu-latest
environment: Production (Bot)
env:
botdirectory: ./CliveBot

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.x'
include-prerelease: true
dotnet-version: '8.x'

- name: Build with dotnet
working-directory: ${{ env.botdirectory }}
run: dotnet build --configuration Release

- name: dotnet publish
working-directory: ${{ env.botdirectory }}
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/clivebot
run: dotnet publish -c Release

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: clivebot
path: ${{env.DOTNET_ROOT}}/clivebot
path: ${{env.botdirectory}}/bin/Release/net8.0/publish

buildweb:
name: Build Web
build-backend-web:
name: Build Backend Web
runs-on: ubuntu-latest
environment: Production (Web)
env:
webdirectory: ./Web

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.x'
include-prerelease: true
dotnet-version: '8.x'

- name: Build with dotnet
working-directory: ${{ env.webdirectory }}
run: dotnet build --configuration Release

- name: dotnet publish
working-directory: ${{ env.webdirectory }}
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/web
run: dotnet publish -c Release

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: webapp
path: ${{env.DOTNET_ROOT}}/web
name: webbackend
path: ${{env.webdirectory}}/bin/Release/net8.0/publish/

test-build-frontend-web:
name: Test Build Frontend Web
runs-on: ubuntu-latest
environment: Production (Web)

env:
webdirectory: ./Web/Client

steps:
- uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v1

- name: Package Install
working-directory: ${{env.webdirectory}}
run: bun install

- name: Build Web Project
working-directory: ${{env.webdirectory}}
run: bun run build

- name: Test Project
working-directory: ${{env.webdirectory}}
run: bun run test --if-present

# MIGRATIONS
migrations:
name: Database Migrations
runs-on: ubuntu-latest
needs: [buildbot, buildweb]
needs: [build-bot, build-backend-web, test-build-frontend-web]
env:
dbdirectory: ./Database

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
sparse-checkout: Database

- name: Set up .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.x'
include-prerelease: true
dotnet-version: '8.x'

- name: Set up .NET EF Core Tools
run: dotnet tool install --global dotnet-ef
Expand All @@ -97,48 +123,77 @@ jobs:


# DEPLOYMENT
deploybot:
deploy-bot:
name: Deploy Bot
runs-on: ubuntu-latest
needs: [buildbot, migrations]
needs: [migrations, build-bot]
environment:
name: 'Production (Bot)'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: clivebot

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
uses: azure/webapps-deploy@v3
with:
app-name: 'FFXVI-Clive-Bot'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_6B7928DA4B7E4D72942283AFBF82D918 }}
package: .

deployweb:
name: Deploy Web
deploy-web-backend:
name: Deploy Web Backend
runs-on: ubuntu-latest
needs: [buildweb, migrations]
needs: [migrations, build-backend-web]
environment:
name: 'Production (Web)'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: webapp
name: webbackend

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
uses: azure/webapps-deploy@v3
with:
app-name: 'FFXVI-Clive-Bot-Web'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_963A587B3B4944D7B3B56A788FCE27C1 }}
package: .

deploy-web-frontend:
name: Deploy Web Frontend
runs-on: ubuntu-latest
needs: [migrations, test-build-frontend-web]
environment:
name: 'Production (Web)'
url: ${{ steps.builddeploy.outputs.static_web_app_url }}

steps:
- uses: actions/checkout@v4
with:
submodules: true
lfs: false
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_YELLOW_GRASS_0D78F5703 }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "Web/Client" # App source code path
api_location: "Web/Client/lib/api/functions/" # Api source code path - optional
output_location: "" # Built app content directory - optional
###### End of Repository/Build Configurations ######
env:
NEXT_PUBLIC_API_URL: ${{ vars.API_URL }}
44 changes: 44 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnPaste": false, // required
"editor.formatOnType": false, // required
"editor.formatOnSave": true, // optional
"editor.codeActionsOnSave": {
"quickfix.biome": "explicit",
"source.organizeImports.biome": "explicit"
},
"css.customData": [".vscode/tailwind.json"],
"files.associations": {
"*.css": "tailwindcss"
},
"editor.quickSuggestions": {
"strings": "on"
},
"typescript.preferences.importModuleSpecifier": "non-relative",
"javascript.preferences.importModuleSpecifier": "non-relative",
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": [
"*.github/workflows/*.yaml",
"*.github/workflows/*.yml"
],
"https://json.schemastore.org/github-action.json": [
"action.yaml",
"action.yml"
]
},
"[yml]": {
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.autoIndent": "keep",
"diffEditor.ignoreTrimWhitespace": false,
"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": true
}
},
"[github-actions-workflow]": {
"editor.insertSpaces": true,
"editor.tabSize": 2
}
}
38 changes: 20 additions & 18 deletions Application/Application.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>CliveBot.Application</AssemblyName>
<RootNamespace>CliveBot.Application</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>CliveBot.Application</AssemblyName>
<RootNamespace>CliveBot.Application</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.4.0" />
<PackageReference Include="MediatR" Version="11.1.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Azure\Azure.csproj" />
<ProjectReference Include="..\Database\Database.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="MediatR" Version="12.2.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Azure\Azure.csproj" />
<ProjectReference Include="..\Database\Database.csproj" />
</ItemGroup>

</Project>
4 changes: 1 addition & 3 deletions Application/Characters/Commands/Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ public class CommandValidator : AbstractValidator<Command>
public CommandValidator() { }
}

public class Handler : BaseHandler, IRequestHandler<Command, CharacterDto>
public class Handler(ApplicationDbContext context, IConfiguration config) : BaseHandler(context, config), IRequestHandler<Command, CharacterDto>
{
public Handler(ApplicationDbContext context, IConfiguration config) : base(context, config) { }

public async Task<CharacterDto> Handle(Command request, CancellationToken cancellationToken)
{
var character = new Character
Expand Down
4 changes: 1 addition & 3 deletions Application/Characters/Commands/Edit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ public class CommandValidator : AbstractValidator<Command>
public CommandValidator() { }
}

public class Handler : BaseHandler, IRequestHandler<Command, CharacterDto>
public class Handler(ApplicationDbContext context, IConfiguration config) : BaseHandler(context, config), IRequestHandler<Command, CharacterDto>
{
public Handler(ApplicationDbContext context, IConfiguration config) : base(context, config) { }

public async Task<CharacterDto> Handle(Command request, CancellationToken cancellationToken)
{
var character = await _context.Characters
Expand Down
4 changes: 1 addition & 3 deletions Application/Characters/Commands/NoteCreate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ public class CommandValidator : AbstractValidator<Command>
public CommandValidator() { }
}

public class Handler : BaseHandler, IRequestHandler<Command, CharacterNoteDto>
public class Handler(ApplicationDbContext context, IConfiguration config) : BaseHandler(context, config), IRequestHandler<Command, CharacterNoteDto>
{
public Handler(ApplicationDbContext context, IConfiguration config) : base(context, config) { }

public async Task<CharacterNoteDto> Handle(Command request, CancellationToken cancellationToken)
{
var character = await _context.Characters.FirstOrDefaultAsync(
Expand Down
4 changes: 1 addition & 3 deletions Application/Characters/Commands/NoteEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ public class CommandValidator : AbstractValidator<Command>
public CommandValidator() { }
}

public class Handler : BaseHandler, IRequestHandler<Command, CharacterNoteDto>
public class Handler(ApplicationDbContext context, IConfiguration config) : BaseHandler(context, config), IRequestHandler<Command, CharacterNoteDto>
{
public Handler(ApplicationDbContext context, IConfiguration config) : base(context, config) { }

public async Task<CharacterNoteDto> Handle(Command request, CancellationToken cancellationToken)
{
var note = await _context.CharacterNotes
Expand Down
Loading

0 comments on commit 12c776b

Please sign in to comment.