Skip to content

Commit

Permalink
Start workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickklaeren committed Nov 11, 2023
1 parent 79318ef commit cd98078
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 39 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
59 changes: 21 additions & 38 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build & Deploy

on:
Expand All @@ -12,48 +9,34 @@ on:
- main
workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'

- name: Build with dotnet
run: dotnet build --configuration Release
- uses: actions/checkout@v4

- name: dotnet publish
run: dotnet publish src/Accord.Web/Accord.Web.csproj -c Release -o ${{env.DOTNET_ROOT}}/myapp

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
- name: Authorise Registry
uses: docker/login-action@v3
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/myapp

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
name: .net-app

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and publish Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
app-name: 'csharpdiscord'
slot-name: 'production'
publish-profile: ${{ secrets.AzureAppService_PublishProfile_29e2c793b82f4b3b9de068f75b4f6548 }}
package: .
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest

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

- name: Set up .NET Core
uses: actions/setup-dotnet@v1
Expand Down
10 changes: 10 additions & 0 deletions src/Accord.Web/Accord.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AspNet.Security.OAuth.Discord" Version="7.0.0" />
<PackageReference Include="AutoConstructor" Version="3.2.5">
Expand All @@ -23,4 +27,10 @@
<ProjectReference Include="..\Accord.Services\Accord.Services.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="..\..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup>

</Project>
23 changes: 23 additions & 0 deletions src/Accord.Web/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["src/Accord.Web/Accord.Web.csproj", "src/Accord.Web/"]
COPY ["src/Accord.Bot/Accord.Bot.csproj", "src/Accord.Bot/"]
COPY ["src/Accord.Services/Accord.Services.csproj", "src/Accord.Services/"]
COPY ["src/Accord.Domain/Accord.Domain.csproj", "src/Accord.Domain/"]
RUN dotnet restore "src/Accord.Web/Accord.Web.csproj"
COPY . .
WORKDIR "/src/src/Accord.Web"
RUN dotnet build "Accord.Web.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Accord.Web.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Accord.Web.dll"]

0 comments on commit cd98078

Please sign in to comment.