Skip to content

Commit cf866bd

Browse files
committed
Fix container build
1 parent bc81923 commit cf866bd

4 files changed

Lines changed: 27 additions & 70 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,33 @@
1-
name: Docker Image CI
1+
name: Build & Publish Container
22

33
on:
44
push:
5-
branches: [ "master" ]
6-
#pull_request:
7-
# branches: [ "master" ]
5+
branches: [ master ]
86

97
jobs:
10-
11-
build:
12-
8+
publish:
139
runs-on: ubuntu-latest
1410

1511
steps:
16-
17-
- uses: actions/checkout@v3
18-
19-
- name: Move Dockerfile to solution directory
20-
run: mv ./src/BF2WebAdmin.Server/Dockerfile .
21-
22-
#- name: Build the Docker image
23-
# run: docker build . --file Dockerfile --tag bf2-webadmin:$(date +%s)
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Install .NET 9
16+
uses: actions/setup-dotnet@v3
17+
with:
18+
dotnet-version: '9.0.x'
2419

25-
- name: Log in to Docker Hub
26-
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
27-
with:
28-
username: ${{ secrets.DOCKER_USERNAME }}
29-
password: ${{ secrets.DOCKER_PASSWORD }}
20+
- name: Run tests
21+
run: dotnet test
3022

31-
- name: Extract metadata (tags, labels) for Docker
32-
id: meta
33-
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
34-
with:
35-
images: nihlen/bf2-webadmin
36-
tags: |
37-
type=sha
38-
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
39-
40-
- name: Build and push Docker image
41-
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
42-
with:
43-
context: .
44-
push: true
45-
tags: ${{ steps.meta.outputs.tags }}
46-
labels: ${{ steps.meta.outputs.labels }}
23+
- name: Build & push container to Docker Hub
24+
env:
25+
# set these in your repo secrets
26+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
27+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
28+
run: |
29+
dotnet publish -c Release \
30+
-p:ContainerRegistry=docker.io \
31+
-p:ContainerRepository=nihlen/bf2-webadmin \
32+
-p:ContainerImageTags=latest,sha-${{ github.sha }} \
33+
-p:ContainerPush=true

nuget.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/BF2WebAdmin.Server/Dockerfile

Lines changed: 0 additions & 28 deletions
This file was deleted.

test/BF2WebAdmin.Tests/BF2WebAdmin.Tests.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
<PackageReference Include="NSubstitute" Version="5.3.0" />
2222
<PackageReference Include="Verify.Xunit" Version="30.0.0" />
2323
<PackageReference Include="xunit" Version="2.9.3" />
24+
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.0">
25+
<PrivateAssets>all</PrivateAssets>
26+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
27+
</PackageReference>
2428
</ItemGroup>
2529

2630
<ItemGroup>

0 commit comments

Comments
 (0)