阅读此答案后:this
我试图做同样的事情。
我有一个.net核心项目,在我的情况下,我正在使用具有发布版本的存储库,因此,我的appsettings.json
位于存储库的根目录中。
# This is a basic workflow to help you get started with Actions
name: DeployToStaging
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
pull_request:
types: [assigned, opened, synchronize, reopened]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
FTP-Deploy-Action:
name: FTP-Deploy-Action
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 2
- uses: microsoft/variable-substitution@v1
with:
files: '${{env.DOTNET_ROOT}}/appsettings.json'
env:
ConnectionStrings.ToBudget: 'This is just a test'
- name: FTP Deploy
uses: SamKirkland/[email protected]
with:
ftp-server: <MyServer>
# FTP account username
ftp-username: <MyUsername>
ftp-password: ${{ secrets.FtpPassword }}
所以基本上,我想转换我的连接字符串(现在这只是一个测试,将来我会创建一个秘密),然后通过FTP将其推送到服务器。
除变量替换外,一切正常。错误是:没有文件与特定模式匹配:/appsettings.json
任何帮助将不胜感激
刚刚发现了问题。而不是文件:'$ {{env.DOTNET_ROOT}} / appsettings.json'我只需要做文件:'appsettings.json'
现在我有第二个问题。 SamKirkland/[email protected]不喜欢该更改。由于存储库很脏,因此避免了上载。