简体   繁体   English

转换步骤以将 function 应用程序发布到 Azure 管道中的工件到 GitHub 操作

[英]Convert steps to publish function app to artifact in Azure Pipeline to GitHub actions

I have the following three steps to publish a function app to artifact in Azure Pipeline:我有以下三个步骤将 function 应用程序发布到 Azure 管道中的工件:

- task: DotNetCoreCLI@2
  displayName: 'dotnet publish function app'
  inputs:
    command: publish
    arguments: '--configuration Release --output updater_publish_output'
    projects: 'Service/XYZ/Hosts.FA/*.csproj'
    publishWebProjects: false
    modifyOutputPath: false
    zipAfterPublish: false

- task: ArchiveFiles@2
  displayName: 'archive function app files'
  inputs:
    rootFolderOrFile: "$(System.DefaultWorkingDirectory)/updater_publish_output"
    includeRootFolder: false
    archiveFile: "$(System.DefaultWorkingDirectory)/Hosts.FA.zip"
 
- task: PublishBuildArtifacts@1
  displayName: 'publish function app files'
  inputs:
    PathtoPublish: '$(System.DefaultWorkingDirectory)/Hosts.FA.zip'
    ArtifactName: '$(Build.BuildNumber)'

Here is the project structure:这是项目结构:

在此处输入图像描述

I have updated the first step to:我已将第一步更新为:

- name: dotnet publish function app
      run: dotnet publish Service/XYZ/Hosts.FA/Hosts.FA.csproj --configuration Release --output updater_publish_output
   

How do I convert the tasks ArchiveFiles@2 & PublishBuildArtifacts@1 to GitHub Actions?如何将任务 ArchiveFiles@2 和 PublishBuildArtifacts@1 转换为 GitHub 操作?

Use the Upload-Artifact task from here: https://github.com/actions/upload-artifact .使用此处的Upload-Artifact任务: https://github.com/actions/upload-artifact It will replace both ArchiveFiles@2 (zipping) and PublishBuildArtifacts@1 (uploading).它将替换ArchiveFiles@2 (压缩)和PublishBuildArtifacts@1 (上传)。

- uses: actions/upload-artifact@v2
  with:
    name: ${{github.run_number}}
    path: |
      updater_publish_output

As per https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context github.run_number is根据https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context github.run_number

A unique number for each run of a particular workflow in a repository.存储库中特定工作流每次运行的唯一编号。 This number begins at 1 for the workflow's first run, and increments with each new run.对于工作流的第一次运行,此数字从 1 开始,并随着每次新运行而递增。 This number does not change if you re-run the workflow run.如果您重新运行工作流运行,此数字不会改变。

You could also use github.run_id :您还可以使用github.run_id

A unique number for each run within a repository.存储库中每次运行的唯一编号。 This number does not change if you re-run the workflow run.如果您重新运行工作流运行,此数字不会更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM