gpt4 book ai didi

.net - 使用 ftp Github Actions 发布和部署 dotnet

转载 作者:行者123 更新时间:2023-12-05 06:18:39 26 4
gpt4 key购买 nike

我正在尝试将 Github Actions 设置为:-构建.net核心应用程序-测试应用程序(单元测试)- 发布(dotnet 发布)-部署到ftp服务器

我在最后一步遇到了一些问题。我正在使用此操作部署到 ftp:https://github.com/SamKirkland/FTP-Deploy-Action

它总是部署整个存储库,而不仅仅是发布文件。

我的工作流程:

name: BuildAndTest

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.101
- name: Install dependencies
run: dotnet restore
- name: Build with dotnet
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
- name: Publish
run: dotnet publish MyApp.sln --configuration Release --framework netcoreapp3.1 --output ./publish --runtime win-x86 --self-contained true -p:PublishTrimmed=true -p:PublishSingleFile=true
- name: FTP Deploy
uses: SamKirkland/FTP-Deploy-Action@3.0.0
with:
# Deployment destination server & path. Formatted as protocol://domain.com:port/full/destination/path/
ftp-server: ${{ secrets.FTP_SERVER }}
# FTP account username
ftp-username: ${{ secrets.FTP_USERNAME }}
# FTP account password
ftp-password: ${{ secrets.FTP_PASSWORD }}
# The local folder to copy, defaults to root project folder
local-dir: /home/runner/work/MyApp/MyApp/publish/

local-dir 指向我在 dotnet publish 命令中指定的目录

工作流没有失败,但没有传输正确的文件。我错过了什么?

提前致谢!

最佳答案

让它变得简单!!
更改发布命令

-name: Publish
run: dotnet publish -c Release --output ./Release

然后只需发送 Release 文件夹中的文件 local-dir: ./Release/

关于.net - 使用 ftp Github Actions 发布和部署 dotnet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61187476/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com