Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
pull_request:
branches: ["main"]

permissions:
packages: write

jobs:
build-and-test:
runs-on: ubuntu-latest
Expand All @@ -29,3 +32,17 @@ jobs:

- name: Build Docker image
run: docker build -t bottomly .

- name: Login to GitHub Container Registry
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push image to GitHub Container Registry
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
docker tag bottomly ghcr.io/${{ github.repository }}:${{ github.sha }}
docker push ghcr.io/${{ github.repository }}:${{ github.sha }}
23 changes: 11 additions & 12 deletions .github/workflows/push_to_live.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
environment:
name: live
permissions:
packages: read
steps:
# checkout the repo
- name: Checkout GitHub Action
Expand All @@ -19,24 +21,21 @@ jobs:
uses: azure/login@v1.4.5
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Build and push image
uses: azure/docker-login@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker build . -t ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }}
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to Azure Container Instances
uses: azure/aci-deploy@v1
with:
resource-group: ${{ secrets.RESOURCE_GROUP }}
dns-name-label: ${{ secrets.RESOURCE_GROUP }}live${{ github.run_number }}
image: ${{ secrets.REGISTRY_LOGIN_SERVER }}/bottomly:${{ github.sha }}
registry-login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }}
registry-username: ${{ secrets.REGISTRY_USERNAME }}
registry-password: ${{ secrets.REGISTRY_PASSWORD }}
image: ghcr.io/${{ github.repository }}:${{ github.sha }}
registry-login-server: ghcr.io
registry-username: ${{ github.actor }}
registry-password: ${{ secrets.GITHUB_TOKEN }}
name: bottomly-live
location: uk south
environment-variables: bottomly_giphy_api_key=${{ secrets.GIPHY_API_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion Bottomly.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
.WithDataVolume()
.WithLifetime(ContainerLifetime.Persistent);

var mongodb = mongo.AddDatabase("mongodb");
var mongodb = mongo.AddDatabase("mongodb", "bottomly");

// var ollama = builder.AddOllama("ollama")
// .WithEnvironment("OLLAMA_API_KEY", builder.Configuration["AppHost:OllamaApiKey"])
Expand Down
5 changes: 4 additions & 1 deletion Bottomly/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
builder.Services.AddSingleton<IMongoDatabase>(sp =>
{
var client = sp.GetRequiredService<IMongoClient>();
return client.GetDatabase("bottomly");
var configuration = sp.GetRequiredService<IConfiguration>();
var connectionString = configuration.GetConnectionString("mongodb")!;
var databaseName = MongoUrl.Create(connectionString).DatabaseName ?? "bottomly";
return client.GetDatabase(databaseName);
});

// Configuration
Expand Down
Loading