-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e9c4b77
Showing
16 changed files
with
589 additions
and
0 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,70 @@ | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- develop | ||
pull_request: | ||
branches: | ||
- master | ||
- develop | ||
types: [opened, reopened, synchronize] | ||
workflow_call: | ||
workflow_dispatch: | ||
|
||
name: ci-build | ||
|
||
env: | ||
DOTNET_VERSION: 8.0.x | ||
REGISTRY: ghcr.io | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup .NET SDK ${{ env.DOTNET_VERSION }} | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: ${{ env.DOTNET_VERSION }} | ||
|
||
- name: Install dependencies | ||
run: dotnet restore | ||
|
||
- name: Build | ||
run: dotnet build --configuration Release --no-restore | ||
|
||
- name: Test | ||
run: dotnet test --no-restore --verbosity normal | ||
|
||
- name: Publish Manager Discord Bot | ||
run: dotnet publish API/API.csproj -c Release -o ./publish/API | ||
|
||
- name: Upload Manager Discord Bot artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ManagerDiscordBot | ||
path: publish/ManagerDiscordBot/* | ||
retention-days: 1 | ||
if-no-files-found: error | ||
|
||
containerize: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
sparse-checkout: .github | ||
|
||
- uses: ./.github/actions/containerize | ||
with: | ||
registry: ghcr.io | ||
registry-path: ${{ github.repository_owner }}/manager-discord-bot | ||
registry-username: ${{ github.actor }} | ||
registry-password: ${{ secrets.GITHUB_TOKEN }} | ||
artifact-name: ManagerDiscordBot | ||
push-image: ${{ github.ref_type == 'branch' && github.ref_protected && github.event_name != 'pull_request' }} |
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,62 @@ | ||
name: containerize | ||
description: Builds and pushes the frontend Docker image | ||
inputs: | ||
registry: | ||
required: true | ||
description: Container registry to push the image to | ||
registry-path: | ||
required: true | ||
description: Path to the image in the container registry | ||
registry-username: | ||
required: true | ||
description: Username to log in to the container registry | ||
registry-password: | ||
required: true | ||
description: Password to log in to the container registry | ||
artifact-name: | ||
required: true | ||
description: Name of the artifact to upload | ||
push-image: | ||
required: true | ||
description: If true, pushes the image to the registry | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Download internal artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ inputs.artifact-name }} | ||
|
||
- name: Set up Docker Build | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ inputs.registry }} | ||
username: ${{ inputs.registry-username }} | ||
password: ${{ inputs.registry-password }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ inputs.registry }}/${{ inputs.registry-path }} | ||
flavor: | | ||
latest=false | ||
tags: | | ||
type=raw,value={{branch}},enable=${{ github.ref_type == 'branch' && github.event_name != 'pull_request' }} | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0') && !startsWith(github.ref, 'refs/tags/0') }} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=semver,pattern={{major}}.{{minor}}.{{patch}} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: ${{ inputs.push-image }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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 @@ | ||
bin/ | ||
obj/ | ||
/packages/ | ||
riderModule.iml | ||
/_ReSharper.Caches/ | ||
.idea | ||
.vs |
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,6 @@ | ||
FROM mcr.microsoft.com/dotnet/runtime:8-alpine | ||
WORKDIR /app | ||
COPY publish . | ||
RUN apk add --no-cache icu-libs | ||
|
||
ENTRYPOINT ["dotnet", "OpenShock.ManagerDiscordBot.dll"] |
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,16 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ManagerDiscordBot", "ManagerDiscordBot\ManagerDiscordBot.csproj", "{AD61D66E-83BA-4DE4-BBAC-AA47C1C357B8}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{AD61D66E-83BA-4DE4-BBAC-AA47C1C357B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{AD61D66E-83BA-4DE4-BBAC-AA47C1C357B8}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{AD61D66E-83BA-4DE4-BBAC-AA47C1C357B8}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{AD61D66E-83BA-4DE4-BBAC-AA47C1C357B8}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
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,12 @@ | ||
using Discord.Interactions; | ||
|
||
namespace OpenShock.ManagerDiscordBot.Commands; | ||
|
||
public sealed class TestCommand : InteractionModuleBase | ||
{ | ||
[SlashCommand("test", "test")] | ||
public async Task Execute() | ||
Check warning on line 8 in ManagerDiscordBot/Commands/TestCommand.cs GitHub Actions / build
Check warning on line 8 in ManagerDiscordBot/Commands/TestCommand.cs GitHub Actions / build
|
||
{ | ||
|
||
} | ||
} |
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,15 @@ | ||
using Discord; | ||
using Discord.Interactions; | ||
|
||
namespace OpenShock.ManagerDiscordBot.Commands; | ||
|
||
public sealed class WikiCommand : InteractionModuleBase | ||
{ | ||
[SlashCommand("wiki", "Links to wiki")] | ||
public async Task Execute() | ||
{ | ||
var embed = new EmbedBuilder().WithDescription("https://wiki.openshock.org/").WithColor(Color.Blue).WithTitle("Wiki").Build(); | ||
|
||
await RespondAsync(embed: embed); | ||
} | ||
} |
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,29 @@ | ||
using Discord; | ||
using Discord.WebSocket; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace OpenShock.ManagerDiscordBot.Events; | ||
|
||
public static class UserJoinEvent | ||
{ | ||
public const ulong WelcomeChannelId = 1224440439646457950; | ||
|
||
public static async Task ClientOnUserJoined(SocketGuildUser userJoin) | ||
{ | ||
var general = userJoin.Guild.GetChannel(WelcomeChannelId) as SocketTextChannel; | ||
if (general == null) | ||
{ | ||
OpenShockManagerBot.Logger.LogWarning("Could not find welcome channel"); | ||
return; | ||
} | ||
|
||
var embed = new EmbedBuilder().WithAuthor(userJoin.Username, userJoin.GetAvatarUrl()) | ||
.WithDescription($"Welcome to the server, {userJoin.Mention}!") | ||
.WithColor(14764653) | ||
.WithCurrentTimestamp() | ||
.Build(); | ||
|
||
|
||
await general.SendMessageAsync(embed: embed); | ||
} | ||
} |
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,6 @@ | ||
namespace OpenShock.ManagerDiscordBot; | ||
|
||
public sealed class ManagerBotConfig | ||
{ | ||
public required string Token { get; init; } | ||
} |
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,50 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<AssemblyName>OpenShock.ManagerDiscordBot</AssemblyName> | ||
<RootNamespace>OpenShock.ManagerDiscordBot</RootNamespace> | ||
<Company>OpenShock</Company> | ||
<AssemblyVersion>0.0.1</AssemblyVersion> | ||
<FileVersion>0.0.1</FileVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Discord.Addons.Hosting" Version="6.0.0" /> | ||
<PackageReference Include="Discord.Net" Version="3.14.1" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.3" /> | ||
<PackageReference Include="Microsoft.Extensions.ApiDescription.Client" Version="8.0.3"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" /> | ||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" /> | ||
<PackageReference Include="OneOf" Version="3.0.263" /> | ||
<PackageReference Include="Serilog" Version="3.1.1" /> | ||
<PackageReference Include="Serilog.Extensions.Autofac.DependencyInjection" Version="5.0.0" /> | ||
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" /> | ||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" /> | ||
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" /> | ||
<PackageReference Include="Serilog.Sinks.Grafana.Loki" Version="8.3.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="appsettings.json" /> | ||
<Content Include="appsettings.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.