Use this guidance to rewrite Azure Pipelines (Build and Release) Tasks on GitHub Actions. To check each implmentation, please access PipelineToActions GitHub Pages.
References
Contribute
steps:
- task: AzureCLI@2
displayName: 'Azure CLI '
inputs:
azureSubscription: '[Azure Subscription]'
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
az account show
az storage -h
- name: Azure Login
uses: Azure/login@v1.1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Azure CLI script
uses: azure/CLI@v1
with:
azcliversion: 2.0.72
inlineScript: |
az account show
az storage -h
steps:
- task: SqlAzureDacpacDeployment@1
displayName: 'Azure SQL DacpacTask'
inputs:
azureSubscription: '[Subscription Name]'
ServerName: '$(SQLServer)'
DatabaseName: '$(SQLDatabase)'
SqlUsername: '$(Login)'
SqlPassword: '$(Pwd)'
DacpacFile: '$(System.DefaultWorkingDirectory)/_[Project Name]/drop/[Project Name]/bin/Release/[Project Name].dacpac'
- name: Azure SQL Deploy
uses: Azure/sql-action@v1
with:
server-name: ${{secrets.SQL_SERVERNAME}}
connection-string: ${{secrets.AZURE_SQL_CONNECTION_STRING}}
dacpac-package: ./[Project Name]/bin/${{env.buildConfiguration}}/[Project Name].dacpac
steps:
- task: AzureWebApp@1
displayName: 'Azure Web App'
inputs:
azureSubscription: '[Subscription]'
appType: webApp
appName: [App Name]
package: '$(System.DefaultWorkingDirectory)\**\*.zip'
- name: Azure Login
uses: Azure/login@v1.1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v1
with:
app-name: '[App Name]'
package: ${{env.DOTNET_ROOT}}/myapp
steps:
- task: Docker@2
displayName: Login to Docker Hub
inputs:
command: login
containerRegistry: dockerHubServiceConnection
- task: Docker@2
displayName: Build and Push
inputs:
command: buildAndPush
repository: someUser/contoso
tags: |
tag1
tag2
uses: docker/build-push-action@v1
with:
username: ${{secrets.DOCKER_USERNAME}}
password: ${{secrets.DOCKER_PASSWORD}}
repository: myorg/myrepository
tags: latest
steps:
- task: DotNetCoreCLI@2
displayName: Restoring .Net packages
inputs:
command: 'restore'
- task: DotNetCoreCLI@2
displayName: Building code
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: Running unit tests
inputs:
command: test
projects: '**/*Tests/*.csproj'
arguments: '--configuration $(buildConfiguration)'
# Install .Net Core SDK: https://github.com/actions/setup-dotnet
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
#MSBuild
steps:
- task: VSBuild@1
displayName: 'Build solution'
inputs:
solution: '$(Parameters.solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
#MSDeploy
steps:
- task: IISWebAppDeploymentOnMachineGroup@0
displayName: 'Deploy IIS Website/App: '
inputs:
WebSiteName: $(WebSiteName)
env:
Solution_Name: 'mySoltion.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
WebSiteName: 'mySite'
zipName: 'mySolution.zip'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Nuget.exe
uses: warrenbuckley/Setup-Nuget@v1
- name: Restore Packages
run: nuget restore $env:Solution_Name
- name: Setup MSbuild.exe
uses: warrenbuckley/Setup-MSBuild@v1
- name: Build using MSBuild
run: msbuild $env:Solution_Name /p:platform=$env:buildPlatform /p:Configuration=$env:buildConfiguration /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation='C:\myapp'
- name: Run MSDeploy.exe
run: msdeploy -verb:sync -source:package=C:\myapp\${{ env.zipName }} -dest:auto -setParam:name=`'IIS Web Application Name`',value=$env:WebSiteName -enableRule:DoNotDeleteRule
steps:
- task: MSBuild@1
displayName: 'Build solution **/*.sln'
inputs:
platform: '$(BuildPlatform)'
configuration: '$(Buildconfiguration)'
msbuildArguments: '/p:OutputPath=$(Build.ArtifactStagingDirectory)'
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@2008f912f56e61277eefaac6d1888b750582aa16
# Create the app package by building and packaging the Windows Application Packaging project
- name: Run Msbuild
run: msbuild $env:Solution_Name /p:platform=$env:buildPlatform /p:Configuration=$env:buildConfiguration
steps:
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: '*.yml'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
publishLocation: 'Container'
- name: Copy JMeter Files
shell: pwsh
run: |
Copy-Item -Path ./deploy.yml -Destination $ -Force
- name: Publish Artifacts
uses: actions/upload-artifact@v1.0.0
with:
name: drop
path: $
Manifest Versioning Build Tasks
steps:
- task: VersionJSONFile@2
inputs:
Path: '$(Build.SourcesDirectory)'
recursion: True
VersionNumber: '$(Build.BuildNumber)'
useBuildNumberDirectly: False
VersionRegex: '\d+\.\d+\.\d+\.\d+'
versionForJSONFileFormat: '{1}.{2}.{3}'
FilenamePattern: 'package.json'
OutputVersion: 'OutputedVersion'
- name: Apply Version to JSON file
uses: rfennell/JSONFileVersioner@v1
with:
path: 'testdata'
field: 'version'
VersionNumber: '1.2.3'
filenamepattern: '.json'
recursion: 'true'
steps:
- task: VSBuild@1
displayName: 'Build solution'
inputs:
solution: '**\*.sln'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@2008f912f56e61277eefaac6d1888b750582aa16
# Create the app package by building and packaging the Windows Application Packaging project
- name: Run Msbuild
run: msbuild $env:Solution_Name /p:platform=$env:buildPlatform /p:Configuration=$env:buildConfiguration
Contributions to Pipelines to GitHub Actions are welcome. Please fork this repo.
ReadMe.md
a respective task/action that you want to document (Table of contents
section and link to task markdown).
Tasks
folder and describe Tasks from Azure Pipelines and respective Actions from GitHub. Use as an example DotNetCore.