chore: working on preparations for deployment
This commit is contained in:
@@ -8,7 +8,7 @@ on:
|
|||||||
- 'src/**'
|
- 'src/**'
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build Docker Image
|
name: Build Docker Images
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
version: ${{ steps.version.outputs.version }}
|
version: ${{ steps.version.outputs.version }}
|
||||||
@@ -25,14 +25,27 @@ jobs:
|
|||||||
run: echo "version=$(date +%Y.%m.%d.%H%M%S)" >> $GITHUB_OUTPUT
|
run: echo "version=$(date +%Y.%m.%d.%H%M%S)" >> $GITHUB_OUTPUT
|
||||||
- name: Build Docker image
|
- name: Build Docker image
|
||||||
run: |
|
run: |
|
||||||
TAG=${{ secrets.DOCKERHUB_USERNAME }}/steves-bot:${{ steps.version.outputs.version }}
|
WORKER_TAG=${{ secrets.DOCKERHUB_USERNAME }}/steves-bot:worker-${{ steps.version.outputs.version }}
|
||||||
docker build -t $TAG src
|
docker build -f src/StevesBot.Worker.Dockerfile -t $WORKER_TAG src
|
||||||
docker push $TAG
|
docker push $WORKER_TAG
|
||||||
|
WEBHOOK_TAG=${{ secrets.DOCKERHUB_USERNAME }}/steves-bot:webhook-${{ steps.version.outputs.version }}
|
||||||
|
docker build -f src/StevesBot.Webhook.Dockerfile -t $WEBHOOK_TAG src
|
||||||
|
docker push $WEBHOOK_TAG
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy Docker Image
|
name: Deploy Docker Images
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build
|
needs: build
|
||||||
steps:
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Copy compose file to server
|
||||||
|
uses: appleboy/scp-action@v1
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.SSH_HOST }}
|
||||||
|
username: ${{ secrets.SSH_USERNAME }}
|
||||||
|
key: ${{ secrets.SSH_KEY }}
|
||||||
|
source: src/compose.yml
|
||||||
|
target: steves-bot
|
||||||
- name: Run image on server
|
- name: Run image on server
|
||||||
uses: appleboy/ssh-action@v1
|
uses: appleboy/ssh-action@v1
|
||||||
with:
|
with:
|
||||||
@@ -42,25 +55,32 @@ jobs:
|
|||||||
script: |
|
script: |
|
||||||
cd steves-bot
|
cd steves-bot
|
||||||
|
|
||||||
echo 'Logging__LogLevel__Default=Debug' >> .env
|
echo 'WORKER_VERSION=worker-${{ needs.build.outputs.version }}' > .env
|
||||||
echo 'Logging__LogLevel__Microsoft=Debug' >> .env
|
echo 'WEBHOOK_VERSION=webhook-${{ needs.build.outputs.version }}' > .env
|
||||||
echo 'Logging__LogLevel__Microsoft.Hosting.Lifetime=Debug' >> .env
|
|
||||||
echo 'DiscordClientOptions__ApiUrl=${{ vars.DISCORD_API_URL }}' >> .env
|
echo 'DiscordClientOptions__ApiUrl=${{ vars.DISCORD_API_URL }}' >> .env
|
||||||
echo 'DiscordClientOptions__AppToken=${{ secrets.DISCORD_APP_TOKEN }}' >> .env
|
echo 'DiscordClientOptions__AppToken=${{ secrets.DISCORD_APP_TOKEN }}' >> .env
|
||||||
echo 'DiscordClientOptions__Intents=${{ vars.DISCORD_INTENTS }}' >> .env
|
echo 'DiscordClientOptions__Intents=${{ vars.DISCORD_INTENTS }}' >> env
|
||||||
echo 'SeqOptions__ServerUrl=${{ secrets.SEQ_SERVER_URL }}' >> .env
|
|
||||||
echo 'SeqOptions__ApiKeyHeader=${{ vars.SEQ_API_KEY_HEADER }}' >> .env
|
|
||||||
echo 'SeqOptions__ApiKey=${{ secrets.SEQ_API_KEY }}' >> .env
|
|
||||||
echo 'DOTNET_ENVIRONMENT=Production' >> .env
|
|
||||||
|
|
||||||
docker stop steves-bot
|
echo 'SEQ_SERVER_URL=${{ secrets.SEQ_SERVER_URL }}' >> .env
|
||||||
docker rm steves-bot
|
echo 'SEQ_API_KEY_HEADER=${{ vars.SEQ_API_KEY_HEADER }}' >> .env
|
||||||
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/steves-bot:${{ needs.build.outputs.version }}
|
echo 'SEQ_WORKER_API_KEY=${{ secrets.SEQ_WORKER_API_KEY }}' >> .env
|
||||||
docker run \
|
echo 'SEQ_WEBHOOK_API_KEY=${{ secrets.SEQ_WEBHOOK_API_KEY }}' >> .env
|
||||||
--name steves-bot \
|
|
||||||
--restart always \
|
echo 'YOUTUBE_BASE_URL=${{ vars.YOUTUBE_BASE_URL }}' >> .env
|
||||||
--env-file .env \
|
echo 'YOUTUBE_API_KEY=${{ secrets.YOUTUBE_API_KEY }}' >> .env
|
||||||
-d \
|
|
||||||
${{ secrets.DOCKERHUB_USERNAME }}/steves-bot:${{ needs.build.outputs.version }}
|
echo 'SUBSCRIPTION_CALLBACK_URL=${{ secrets.SUBSCRIPTION_CALLBACK_URL }}' >> .env
|
||||||
|
echo 'SUBSCRIPTION_TOPIC_URL=${{ secrets.SUBSCRIPTION_TOPIC_URL }}' >> .env
|
||||||
rm .env
|
|
||||||
|
echo 'PUBSUB_BASE_URL=${{ vars.PUBSUB_BASE_URL }}' >> .env
|
||||||
|
|
||||||
|
echo 'DISCORD_NOTIFICATION_CHANNEL_ID=${{ vars.DISCORD_NOTIFICATION_CHANNEL_ID }}' >> .env
|
||||||
|
echo 'DISCORD_NOTIFICATION_MESSAGE_FORMAT="${{ vars.DISCORD_NOTIFICATION_MESSAGE_FORMAT }}"' >> .env
|
||||||
|
|
||||||
|
docker compose -f compose.yml down
|
||||||
|
docker compose -f compose.yml pull
|
||||||
|
docker compose -f compose.yml up -d --wait
|
||||||
|
|
||||||
|
rm compose.yml
|
||||||
|
rm .env
|
||||||
|
|||||||
@@ -33,8 +33,10 @@ jobs:
|
|||||||
run: dotnet tool install -g dotnet-reportgenerator-globaltool
|
run: dotnet tool install -g dotnet-reportgenerator-globaltool
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: dotnet test src
|
run: dotnet test src
|
||||||
|
- name: Merge coverage reports
|
||||||
|
run: reportgenerator "-reports:src/tests/*/TestResults/*/coverage.cobertura.xml" "-reporttypes:Html;Cobertura" "-targetdir:src/tests/TestResults/Coverage"
|
||||||
- name: Upload code coverage
|
- name: Upload code coverage
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: html-report
|
name: coverage-reports
|
||||||
path: src/StevesBot.Worker.Tests/TestResults/Coverage/Report/
|
path: src/tests/TestResults/Coverage
|
||||||
|
|||||||
+2
-2
@@ -22,7 +22,7 @@ services:
|
|||||||
- DiscordNotificationOptions__MessageFormat="${DISCORD_NOTIFICATION_MESSAGE_FORMAT}"
|
- DiscordNotificationOptions__MessageFormat="${DISCORD_NOTIFICATION_MESSAGE_FORMAT}"
|
||||||
- SeqOptions__ServerUrl=${SEQ_SERVER_URL}
|
- SeqOptions__ServerUrl=${SEQ_SERVER_URL}
|
||||||
- SeqOptions__ApiKeyHeader=${SEQ_API_KEY_HEADER}
|
- SeqOptions__ApiKeyHeader=${SEQ_API_KEY_HEADER}
|
||||||
- SeqOptions__ApiKey=${SEQ_API_KEY}
|
- SeqOptions__ApiKey=${SEQ_WEBHOOK_API_KEY}
|
||||||
- DOTNET_ENVIRONMENT=Production
|
- DOTNET_ENVIRONMENT=Production
|
||||||
worker:
|
worker:
|
||||||
container_name: steves-bot-worker
|
container_name: steves-bot-worker
|
||||||
@@ -36,5 +36,5 @@ services:
|
|||||||
- DiscordClientOptions__Intents=${DISCORD_INTENTS}
|
- DiscordClientOptions__Intents=${DISCORD_INTENTS}
|
||||||
- SeqOptions__ServerUrl=${SEQ_SERVER_URL}
|
- SeqOptions__ServerUrl=${SEQ_SERVER_URL}
|
||||||
- SeqOptions__ApiKeyHeader=${SEQ_API_KEY_HEADER}
|
- SeqOptions__ApiKeyHeader=${SEQ_API_KEY_HEADER}
|
||||||
- SeqOptions__ApiKey=${SEQ_API_KEY}
|
- SeqOptions__ApiKey=${SEQ_WORKER_API_KEY}
|
||||||
- DOTNET_ENVIRONMENT=Production
|
- DOTNET_ENVIRONMENT=Production
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ global using StevesBot.Library.Discord.Common;
|
|||||||
global using StevesBot.Library.Discord.Rest;
|
global using StevesBot.Library.Discord.Rest;
|
||||||
global using StevesBot.Library.Discord.Rest.Requests;
|
global using StevesBot.Library.Discord.Rest.Requests;
|
||||||
global using StevesBot.Library.Telemetry;
|
global using StevesBot.Library.Telemetry;
|
||||||
|
global using StevesBot.Webhook.Telemetry;
|
||||||
global using StevesBot.Webhook.YouTube;
|
global using StevesBot.Webhook.YouTube;
|
||||||
global using StevesBot.Webhook.YouTube.Data;
|
global using StevesBot.Webhook.YouTube.Data;
|
||||||
global using StevesBot.Webhook.YouTube.Handlers;
|
global using StevesBot.Webhook.YouTube.Handlers;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class HostExtensionsTests
|
|||||||
.NotBeNull();
|
.NotBeNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestInstrumentation : IInstrumentation
|
private sealed class TestInstrumentation : IInstrumentation
|
||||||
{
|
{
|
||||||
public string SourceName { get; } = "TestSource";
|
public string SourceName { get; } = "TestSource";
|
||||||
public string SourceVersion { get; } = "1.0.0";
|
public string SourceVersion { get; } = "1.0.0";
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace StevesBot.Worker.Tests.Unit;
|
namespace StevesBot.Worker.Tests.Unit;
|
||||||
|
|
||||||
public sealed class DiscordGatewayClientTests : IDisposable
|
public sealed class DiscordGatewayClientTests : IDisposable
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace StevesBot.Worker.Tests.Unit;
|
namespace StevesBot.Worker.Tests.Unit;
|
||||||
|
|
||||||
public sealed class StevesBotWorkerInstrumentationTests : IDisposable
|
public sealed class StevesBotWorkerInstrumentationTests : IDisposable
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
global using System.Diagnostics;
|
|
||||||
global using System.Net.WebSockets;
|
global using System.Net.WebSockets;
|
||||||
global using System.Text;
|
global using System.Text;
|
||||||
global using System.Text.Json;
|
global using System.Text.Json;
|
||||||
|
|||||||
Reference in New Issue
Block a user