C# DoctNet还原Dockerfile中的GitHub包
如何在Dockerfile中恢复GitHub包中托管的nuget包 当我创建NuGet.config文件时,我需要在那里设置一个令牌(只有一个只读令牌)来访问GitHub包,即使在公共存储库上也是如此:-(。GitHub会立即删除此密码。还有其他方法吗 Dockerfile:C# DoctNet还原Dockerfile中的GitHub包,c#,docker,nuget-package,github-actions,github-package-registry,C#,Docker,Nuget Package,Github Actions,Github Package Registry,如何在Dockerfile中恢复GitHub包中托管的nuget包 当我创建NuGet.config文件时,我需要在那里设置一个令牌(只有一个只读令牌)来访问GitHub包,即使在公共存储库上也是如此:-(。GitHub会立即删除此密码。还有其他方法吗 Dockerfile: FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build WORKDIR /src COPY ["Deploy_O_Mat.API/Deploy_O_Mat.A
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["Deploy_O_Mat.API/Deploy_O_Mat.API.csproj", "Deploy_O_Mat.API/"]
COPY ["NuGet.config", "Deploy_O_Mat.API/"]
RUN dotnet restore "Deploy_O_Mat.API/Deploy_O_Mat.API.csproj"
COPY . .
WORKDIR "/src/Deploy_O_Mat.API"
RUN dotnet build "Deploy_O_Mat.API.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Deploy_O_Mat.API.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Deploy_O_Mat.API.dll"]
操作(生成-还原不使用NuGet.config文件):
操作(Docker image build和deply不带NuGet.config-不工作):
github个人访问令牌的范围是什么?github个人访问令牌的范围是什么?
name: .NET Core
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.100
source-url: https://nuget.pkg.github.com/Marcel-B/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
name: Publish Docker
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: millegalb/deploy-o-mat
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
source-url: https://nuget.pkg.github.com/Marcel-B/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}