chore: working on preparations for deployment
This commit is contained in:
@@ -8,7 +8,7 @@ on:
|
||||
- 'src/**'
|
||||
jobs:
|
||||
build:
|
||||
name: Build Docker Image
|
||||
name: Build Docker Images
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
@@ -25,14 +25,27 @@ jobs:
|
||||
run: echo "version=$(date +%Y.%m.%d.%H%M%S)" >> $GITHUB_OUTPUT
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
TAG=${{ secrets.DOCKERHUB_USERNAME }}/steves-bot:${{ steps.version.outputs.version }}
|
||||
docker build -t $TAG src
|
||||
docker push $TAG
|
||||
WORKER_TAG=${{ secrets.DOCKERHUB_USERNAME }}/steves-bot:worker-${{ steps.version.outputs.version }}
|
||||
docker build -f src/StevesBot.Worker.Dockerfile -t $WORKER_TAG src
|
||||
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:
|
||||
name: Deploy Docker Image
|
||||
name: Deploy Docker Images
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
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
|
||||
uses: appleboy/ssh-action@v1
|
||||
with:
|
||||
@@ -42,25 +55,32 @@ jobs:
|
||||
script: |
|
||||
cd steves-bot
|
||||
|
||||
echo 'Logging__LogLevel__Default=Debug' >> .env
|
||||
echo 'Logging__LogLevel__Microsoft=Debug' >> .env
|
||||
echo 'Logging__LogLevel__Microsoft.Hosting.Lifetime=Debug' >> .env
|
||||
echo 'WORKER_VERSION=worker-${{ needs.build.outputs.version }}' > .env
|
||||
echo 'WEBHOOK_VERSION=webhook-${{ needs.build.outputs.version }}' > .env
|
||||
|
||||
echo 'DiscordClientOptions__ApiUrl=${{ vars.DISCORD_API_URL }}' >> .env
|
||||
echo 'DiscordClientOptions__AppToken=${{ secrets.DISCORD_APP_TOKEN }}' >> .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
|
||||
echo 'DiscordClientOptions__Intents=${{ vars.DISCORD_INTENTS }}' >> env
|
||||
|
||||
docker stop steves-bot
|
||||
docker rm steves-bot
|
||||
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/steves-bot:${{ needs.build.outputs.version }}
|
||||
docker run \
|
||||
--name steves-bot \
|
||||
--restart always \
|
||||
--env-file .env \
|
||||
-d \
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/steves-bot:${{ needs.build.outputs.version }}
|
||||
|
||||
rm .env
|
||||
echo 'SEQ_SERVER_URL=${{ secrets.SEQ_SERVER_URL }}' >> .env
|
||||
echo 'SEQ_API_KEY_HEADER=${{ vars.SEQ_API_KEY_HEADER }}' >> .env
|
||||
echo 'SEQ_WORKER_API_KEY=${{ secrets.SEQ_WORKER_API_KEY }}' >> .env
|
||||
echo 'SEQ_WEBHOOK_API_KEY=${{ secrets.SEQ_WEBHOOK_API_KEY }}' >> .env
|
||||
|
||||
echo 'YOUTUBE_BASE_URL=${{ vars.YOUTUBE_BASE_URL }}' >> .env
|
||||
echo 'YOUTUBE_API_KEY=${{ secrets.YOUTUBE_API_KEY }}' >> .env
|
||||
|
||||
echo 'SUBSCRIPTION_CALLBACK_URL=${{ secrets.SUBSCRIPTION_CALLBACK_URL }}' >> .env
|
||||
echo 'SUBSCRIPTION_TOPIC_URL=${{ secrets.SUBSCRIPTION_TOPIC_URL }}' >> .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
|
||||
- name: Run tests
|
||||
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
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: html-report
|
||||
path: src/StevesBot.Worker.Tests/TestResults/Coverage/Report/
|
||||
name: coverage-reports
|
||||
path: src/tests/TestResults/Coverage
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ services:
|
||||
- DiscordNotificationOptions__MessageFormat="${DISCORD_NOTIFICATION_MESSAGE_FORMAT}"
|
||||
- SeqOptions__ServerUrl=${SEQ_SERVER_URL}
|
||||
- SeqOptions__ApiKeyHeader=${SEQ_API_KEY_HEADER}
|
||||
- SeqOptions__ApiKey=${SEQ_API_KEY}
|
||||
- SeqOptions__ApiKey=${SEQ_WEBHOOK_API_KEY}
|
||||
- DOTNET_ENVIRONMENT=Production
|
||||
worker:
|
||||
container_name: steves-bot-worker
|
||||
@@ -36,5 +36,5 @@ services:
|
||||
- DiscordClientOptions__Intents=${DISCORD_INTENTS}
|
||||
- SeqOptions__ServerUrl=${SEQ_SERVER_URL}
|
||||
- SeqOptions__ApiKeyHeader=${SEQ_API_KEY_HEADER}
|
||||
- SeqOptions__ApiKey=${SEQ_API_KEY}
|
||||
- SeqOptions__ApiKey=${SEQ_WORKER_API_KEY}
|
||||
- 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.Requests;
|
||||
global using StevesBot.Library.Telemetry;
|
||||
global using StevesBot.Webhook.Telemetry;
|
||||
global using StevesBot.Webhook.YouTube;
|
||||
global using StevesBot.Webhook.YouTube.Data;
|
||||
global using StevesBot.Webhook.YouTube.Handlers;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class HostExtensionsTests
|
||||
.NotBeNull();
|
||||
}
|
||||
|
||||
private class TestInstrumentation : IInstrumentation
|
||||
private sealed class TestInstrumentation : IInstrumentation
|
||||
{
|
||||
public string SourceName { get; } = "TestSource";
|
||||
public string SourceVersion { get; } = "1.0.0";
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace StevesBot.Worker.Tests.Unit;
|
||||
|
||||
public sealed class DiscordGatewayClientTests : IDisposable
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace StevesBot.Worker.Tests.Unit;
|
||||
|
||||
public sealed class StevesBotWorkerInstrumentationTests : IDisposable
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
global using System.Diagnostics;
|
||||
global using System.Net.WebSockets;
|
||||
global using System.Text;
|
||||
global using System.Text.Json;
|
||||
|
||||
Reference in New Issue
Block a user