pipeline optimalization #33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish VSIX - Manage-AutomationAccount - azure pipeline task | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- 'Tasks/**/task.json' | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: '2.x' | |
- name: Install Node.js | |
run: | | |
choco install nodejs -y -Force | |
- name: Install tfx-cli | |
run: | | |
npm install -g tfx-cli | |
npm install -g uuid@latest | |
- name: Install VstsTaskSdk | |
run: | | |
# Function to install VstsTaskSdk for a given task | |
function Install-VstsTaskSdk ($taskDirectoryName) { | |
# Get the directory of the script | |
$scriptDirectory = Split-Path $script:MyInvocation.MyCommand.Path | |
# Create absolute path to the task directory | |
$taskDirectory = Join-Path $scriptDirectory "Tasks\$taskDirectoryName" | |
# Navigate to the task directory | |
Write-Host "Do process for $taskDirectoryName task." | |
Write-Host "Navigate to $taskDirectoryName directory." | |
Set-Location -Path $taskDirectory | |
# Create ps_modules directory if it doesn't exist | |
mkdir -p ps_modules | |
# Install VstsTaskSdk | |
Write-Host "$taskDirectoryName VstsTaskSdk installing..." | |
Save-Module –Name VstsTaskSdk –Path .\ps_modules -Force | |
Write-Host "Installing finished." | |
Set-Location -Path (Join-Path $taskDirectory "ps_modules\VstsTaskSdk") | |
Write-Host "$taskDirectoryName directory contains:" | |
ls | |
$sourcePath = Get-Location | |
# find a directory with vstsTaskSdk version | |
$directoryWithFiles = Get-ChildItem -Path $sourcePath -Directory | Where-Object { (Get-ChildItem $_.FullName -File).Count -gt 0 } | Select-Object -First 1 | |
# If directory cointain file, do process | |
if ($directoryWithFiles) { | |
# copy files to root folder | |
Copy-Item -Path "$($directoryWithFiles.FullName)\*" -Destination $sourcePath -Recurse -Force | |
Write-Host "Files from subfolder was copied to root folder ($sourcePath)." | |
# delete subfolder | |
Remove-Item -Path $directoryWithFiles.FullName -Recurse -Force | |
Write-Host "Subfolder was deleted." | |
# get list of files | |
Write-Host "Moved files to: ($sourcePath) after process:" | |
Get-ChildItem -Path $sourcePath | |
} else { | |
Write-Host "There is no directory with files." | |
} | |
# Navigate back to the root folder | |
Set-Location -Path $scriptDirectory | |
} | |
# Install VstsTaskSdk for Manage-AutomationAccount task | |
Install-VstsTaskSdk "Manage-AutomationAccount" | |
# Install VstsTaskSdk for Manage-AutomationWebHook task | |
Install-VstsTaskSdk "Manage-AutomationWebHook" | |
- name: Generate and Upload VSIX file | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.PAT_ROMAN_MANAGE_AUTOMATION_ACCOUNT }} | |
run: | | |
Write-Host "Start generate and upload VSIX file..." | |
tfx extension publish --publisher GreyCorbelSolutions --manifest-globs vss-extension.json --token $env:NODE_AUTH_TOKEN |