Skip to content

Commit 2b66cfb

Browse files
authoredJan 10, 2023
Merge pull request tobyash86#81 from Contrast-Security-OSS/master
Adds Container Image Publishing
2 parents 3ac2a84 + 1956fa1 commit 2b66cfb

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed
 

‎.github/workflows/dotnet.yml

+33-9
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,43 @@ on:
55
branches: [ master ]
66
pull_request:
77
branches: [ master ]
8+
workflow_dispatch: {}
89

910
jobs:
1011
build:
11-
1212
runs-on: ubuntu-latest
13-
13+
permissions:
14+
packages: write
15+
contents: read
16+
env:
17+
IMAGE_NAME: ghcr.io/${{ github.repository }}
18+
PUBLISH: ${{ github.ref == 'refs/heads/master' }}
1419
steps:
1520
- uses: actions/checkout@v2
16-
- name: Setup .NET 7
17-
uses: actions/setup-dotnet@v1
21+
- uses: docker/setup-buildx-action@v2
22+
id: buildx
23+
with:
24+
install: true
25+
version: latest
26+
- uses: docker/login-action@v2
27+
if: ${{ env.PUBLISH }}
28+
with:
29+
registry: ghcr.io
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
- id: meta
33+
uses: docker/metadata-action@v4
34+
with:
35+
images: ${{ env.IMAGE_NAME }}
36+
tags: |
37+
type=sha
38+
type=edge
39+
type=raw,value=latest,enable={{is_default_branch}}
40+
- uses: docker/build-push-action@v3
41+
id: build
1842
with:
19-
dotnet-version: 7.0.100-rc.1.22431.12
20-
- name: Install dependencies
21-
run: dotnet restore
22-
- name: Build
23-
run: dotnet build --configuration Release --no-restore
43+
file: Dockerfile
44+
context: .
45+
push: ${{ env.PUBLISH }}
46+
tags: ${{ steps.meta.outputs.tags }}
47+
labels: ${{ steps.meta.outputs.labels }}

‎Dockerfile

+4
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@ RUN dotnet publish -c release -o /app
1111
FROM mcr.microsoft.com/dotnet/aspnet:7.0
1212
WORKDIR /app
1313
COPY --from=build /app ./
14+
15+
LABEL org.opencontainers.image.source=https://github.com/tobyash86/WebGoat.NET
16+
LABEL org.opencontainers.image.description="WebGoat.NETCore - port of original WebGoat.NET to .NET Core"
17+
1418
ENTRYPOINT ["dotnet", "WebGoat.NET.dll"]

0 commit comments

Comments
 (0)