GH Action to populate build stage yaml files (stable only for now) #25
Workflow file for this run
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
# Copyright (c) Microsoft Corporation. | |
# Licensed under the MIT license. | |
name: Update Channel Based ReleaseStage Yaml Files | |
permissions: | |
contents: read | |
on: | |
workflow_dispatch: | |
inputs: | |
stableReleaseTag: | |
description: 'release tag for stable' | |
required: false | |
previewReleaseTag: | |
description: 'release tag for preview' | |
required: false | |
ltsReleaseTag: | |
description: 'release tag for lts' | |
required: false | |
pull_request: | |
defaults: | |
run: | |
shell: pwsh | |
jobs: | |
update-yamls: | |
name: Update ReleaseStageYaml for Stable Channel | |
timeout-minutes: 15 | |
runs-on: ubuntu-20.04 | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Validate Version Syntax | |
id: validate-version | |
run: | | |
$stableValue = '${{ inputs.stableReleaseTag }}' | |
if (!($stableValue -eq "")) | |
{ | |
if ($stableValue -notmatch '\d+\.\d+\.\d+$') { | |
throw "stable release tag is not for a stable build: '$stableValue'" | |
} | |
} | |
$previewValue = '${{ inputs.previewReleaseTag }}' | |
if (!($previewValue -eq "")) | |
{ | |
if ($previewValue -notmatch '\d+\.\d+\.\d+-(preview|rc)\.\d+$') { | |
throw "preview release tag is not for a preview build: '$previewValue'" | |
} | |
} | |
$ltsValue = '${{ inputs.ltsReleaseTag }}' | |
if (!($ltsValue -eq "")) | |
{ | |
if ($ltsValue -notmatch '\d+\.\d+\.\d+$') { | |
throw "lts release tag is not for a lts build: '$ltsValue'" | |
} | |
} | |
- name: Update ReleaseStageYaml file for Stable | |
run: | | |
$stableValue = '${{ inputs.stableReleaseTag }}' | |
$toolsFolderPath = Join-Path -Path ${{ github.workspace }} -ChildPath 'tools' | |
$buildHelperFolderPath = Join-Path -Path $toolsFolderPath -ChildPath 'buildHelper' | |
$buildHelperModulePath = Join-Path -Path $buildHelperFolderPath -ChildPath 'buildHelper.psm1' | |
Import-Module $buildHelperModulePath | |
if (!($stableValue -eq "")) | |
{ | |
Write-Verbose -Verbose "using stable version: $stableValue" | |
./build.ps1 -UpdateBuildYaml -Channel stable -StableVersion $stableValue -Verbose -Acr All -OsFilter All | |
} | |
else | |
{ | |
# Use the version from channels.json when no version is provided | |
Write-Verbose -Verbose "not using stable version from input as value was $stableValue" | |
./build.ps1 -UpdateBuildYaml -Channel stable -Verbose -Acr All -OsFilter All | |
} | |
- name: Update ReleaseStageYaml file for Preview | |
run: | | |
$previewValue = '${{ inputs.previewReleaseTag }}' | |
$toolsFolderPath = Join-Path -Path ${{ github.workspace }} -ChildPath 'tools' | |
$buildHelperFolderPath = Join-Path -Path $toolsFolderPath -ChildPath 'buildHelper' | |
$buildHelperModulePath = Join-Path -Path $buildHelperFolderPath -ChildPath 'buildHelper.psm1' | |
Import-Module $buildHelperModulePath | |
if (!($previewValue -eq "")) | |
{ | |
./build.ps1 -UpdateBuildYaml -Channel preview -PreviewVersion $previewValue -Verbose -Acr All -OsFilter All | |
} | |
else | |
{ | |
# Use the version from channels.json when no version is provided | |
./build.ps1 -UpdateBuildYaml -Channel preview -Verbose -Acr All -OsFilter All | |
} | |
- name: Update ReleaseStageYaml file for LTS | |
run: | | |
$ltsValue = '${{ inputs.ltsReleaseTag }}' | |
$toolsFolderPath = Join-Path -Path ${{ github.workspace }} -ChildPath 'tools' | |
$buildHelperFolderPath = Join-Path -Path $toolsFolderPath -ChildPath 'buildHelper' | |
$buildHelperModulePath = Join-Path -Path $buildHelperFolderPath -ChildPath 'buildHelper.psm1' | |
Import-Module $buildHelperModulePath | |
if (!($ltsValue -eq "")) | |
{ | |
./build.ps1 -UpdateBuildYaml -Channel lts -LtsVersion $ltsValue -Verbose -Acr All -OsFilter All | |
} | |
else | |
{ | |
# Use the version from channels.json when no version is provided | |
./build.ps1 -UpdateBuildYaml -Channel lts -Verbose -Acr All -OsFilter All | |
} | |
- name: View Updated Files Content | |
run: | | |
$ciFolderPath = Join-Path -Path ${{ github.workspace }} -ChildPath '.vsts-ci' | |
$releaseStageFilePath = Join-Path -Path $ciFolderPath -ChildPath 'stableReleaseStage.yml' | |
$content = Get-Content -Path $releaseStageFilePath | |
Write-Verbose -Verbose "length of content: $($content.Length)" | |
for($i=0; $i -lt $content.Length;$i++) | |
{ | |
Write-Verbose -Verbose $content[$i] | |
} | |
- name: Create Pull Request | |
if: github.event_name == 'workflow_dispatch' | |
id: cpr | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
token: "${{ secrets.PR_PAT }}" | |
commit-message: "Update the stableReleaseStage yaml file" | |
committer: PwshBot <[email protected]> | |
author: PwshBot <[email protected]> | |
title: "Update the stableReleaseStage json" | |
base: master | |
draft: false | |
branch: update-build-yaml-files | |
push-to-fork: pwshBot/PowerShell-Docker |