Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frontload Docs Setup #2282

Merged
merged 10 commits into from
Aug 12, 2024
Merged
80 changes: 51 additions & 29 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ jobs:
HasChanged_automation: ${{ steps.filter.outputs.automation }}
nkdAgility_Ring: ${{ steps.nkdagility.outputs.Ring }}
nkdAgility_WingetApplicationId: ${{ steps.nkdagility.outputs.WingetApplicationId }}
nkdAgility_IsBuildEditBranch: ${{ steps.nkdagility.outputs.IsBuildEditBranch }}
nkdAgility_ReleaseDescription: ${{ steps.nkdagility.outputs.release_description }}
nkdAgility_ReleaseDescriptionState: ${{ steps.nkdagility.outputs.release_description_state }}
nkdAgility_HasChanged_src: ${{ steps.nkdagility.outputs.HasChanged_src }}
nkdAgility_HasChanged_docs: ${{ steps.nkdagility.outputs.HasChanged_docs }}
nkdAgility_HasChanged_automation: ${{ steps.nkdagility.outputs.HasChanged_automation }}
nkdAgility_DocsDeployFolder: ${{ steps.nkdagility.outputs.docs_deploy_folder }}
nkdAgility_DocsVersionFolder: ${{ steps.nkdagility.outputs.docs_version_folder }}
nkdAgility_RunRelease: ${{ steps.nkdagility.outputs.RunRelease }}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -94,34 +96,57 @@ jobs:
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
# Ring Setup
Write-Output "-------------------------------------------"
Write-Output "Ring Control Setup"
Write-Output "-------------------------------------------"
$Ring = "Canary"
$WingetApplicationId = "nkdagility.azure-devops-migration-tools"
$docs_deploy_folder = "./azure-devops-migration-tools/";
$RunCodeRelease = 'false'
$RunDocsRelease = 'false'
switch ($Env:GitVersion_PreReleaseLabel) {
"" {
$Ring = "Release";
$WingetApplicationId = "nkdagility.azure-devops-migration-tools";
$docs_deploy_folder = "./azure-devops-migration-tools/"
$RunRelease = 'true'
}
"Preview" {
$Ring = "Preview";
$WingetApplicationId = "nkdagility.azure-devops-migration-tools.Preview";
$docs_deploy_folder = "./azure-devops-migration-tools/preview/";
$RunRelease = ('${{ steps.filter.outputs.src }}' -eq 'true')
}
default {
$Ring = "Canary";
$WingetApplicationId = "nkdagility.azure-devops-migration-tools.Canary";
$docs_deploy_folder = "./azure-devops-migration-tools/canary/"
$RunRelease = 'false'
}
}
Write-Output "We are running for the $Ring Ring!"
Write-Output "We are focused on Winget ID $WingetApplicationId!"
echo "Ring=$Ring" >> $env:GITHUB_OUTPUT
Write-Output "We are focused on Winget ID $WingetApplicationId!"
echo "WingetApplicationId=$WingetApplicationId" >> $env:GITHUB_OUTPUT
Write-Output "docs_deploy_folder=$docs_deploy_folder"
echo "docs_deploy_folder=$docs_deploy_folder" >> $env:GITHUB_OUTPUT
Write-Output "RunRelease=$RunRelease"
echo "RunRelease=$RunRelease" >> $env:GITHUB_OUTPUT
Write-Output "-------------------------------------------"
# Docs Setup
Write-Output "-------------------------------------------"
Write-Output "Docs"
Write-Output "-------------------------------------------"
$docs_version_folder = "/azure-devops-migration-tools/$Env:GitVersion_SemVer"
Write-Output "docs_version_folder=$docs_version_folder"
echo "docs_version_folder=$docs_version_folder" >> $env:GITHUB_OUTPUT
Write-Output "-------------------------------------------"

$IsBuildEditBranch = $false;
if (("${{ github.ref_name }}").contains("build/")) {
$IsBuildEditBranch = $true;
}
Write-Output "IsBuildEditBranch=$IsBuildEditBranch"
echo "IsBuildEditBranch=$IsBuildEditBranch" >> $env:GITHUB_OUTPUT

# Get-ReleaseDescription
Write-Output "-------------------------------------------"
Write-Output "Get-ReleaseDescription"
Write-Output "-------------------------------------------"
Write-Output "Running Get-ReleaseDescription.ps1"
. .\build\include\Get-ReleaseDescription.ps1
$description = Get-ReleaseDescription -mode log -OPEN_AI_KEY ${{ secrets.OPENAI_API_KEY }}
Expand All @@ -136,7 +161,11 @@ jobs:
echo "release_description<<$EOF" >> $env:GITHUB_OUTPUT
echo $description >> $env:GITHUB_OUTPUT
echo "$EOF" >> $env:GITHUB_OUTPUT

Write-Output "-------------------------------------------"
# HasChanged Setup
Write-Output "-------------------------------------------"
Write-Output "HasChanged Setup"
Write-Output "-------------------------------------------"
if ('${{ steps.filter.outputs.src }}' -eq 'true') {
echo "HasChanged_src=true" >> $env:GITHUB_OUTPUT;
} else {
Expand All @@ -160,6 +189,7 @@ jobs:
} else {
echo "HasChanged_automation=false" >> $env:GITHUB_OUTPUT;
}
Write-Output "-------------------------------------------"

- uses: actions/upload-artifact@v4
with:
Expand All @@ -181,12 +211,14 @@ jobs:
## ${{needs.Setup.outputs.GitVersion_SemVer}} (${{needs.Setup.outputs.nkdAgility_Ring}})
### NKDAgility
- nkdAgility_Ring: ${{needs.Setup.outputs.nkdAgility_Ring}}
- nkdAgility_IsBuildEditBranch: ${{needs.Setup.outputs.nkdAgility_IsBuildEditBranch}}
- nkdAgility_WingetApplicationId: ${{needs.Setup.outputs.nkdAgility_WingetApplicationId}}
- nkdAgility_DocsVersionFolder: ${{needs.Setup.outputs.nkdAgility_DocsVersionFolder}}
- nkdAgility_DocsDeployFolder: ${{needs.Setup.outputs.nkdAgility_DocsDeployFolder}}
- nkdAgility_ReleaseDescriptionState: ${{needs.Setup.outputs.nkdAgility_ReleaseDescriptionState}}
- nkdAgility_HasChanged_src: ${{needs.Setup.outputs.nkdAgility_HasChanged_src}}
- nkdAgility_HasChanged_docs: ${{needs.Setup.outputs.nkdAgility_HasChanged_docs}}
- nkdAgility_HasChanged_automation: ${{needs.Setup.outputs.nkdAgility_HasChanged_automation}}
- nkdAgility_RunRelease: ${{needs.Setup.outputs.nkdAgility_RunRelease}}
### GitVersion
- GitVersion_BranchName: ${{needs.Setup.outputs.GitVersion_BranchName}}
- GitVersion_SemVer: ${{needs.Setup.outputs.GitVersion_SemVer}}
Expand Down Expand Up @@ -331,7 +363,7 @@ jobs:
GitVersion_NuGetVersion: ${{ needs.Setup.outputs.GitVersion_NuGetVersion }}
GitVersion_PreReleaseLabel: ${{ needs.Setup.outputs.GitVersion_PreReleaseLabel }}
needs: [build, Setup]
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_Ring != 'Canary' ) && ( needs.Setup.outputs.nkdAgility_HasChanged_src == 'true' ) }}
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_RunRelease == 'true' ) }}
steps:
- uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -392,7 +424,7 @@ jobs:
env:
GitVersion_SemVer: ${{ needs.Setup.outputs.GitVersion_SemVer }}
needs: [GitHubRelease, Setup]
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_Ring != 'Canary' ) }}
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_RunRelease == 'true' ) }}
steps:
- name: Create Deployment on elmah.io
uses: elmahio/github-create-deployment-action@v1
Expand All @@ -407,7 +439,7 @@ jobs:
name: "Release to Marketplace"
runs-on: ubuntu-latest
needs: [Setup, GitHubRelease]
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_Ring != 'Canary' ) && (needs.Setup.outputs.nkdAgility_HasChanged_src == 'true') }}
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_Ring == 'Release' ) }}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -436,7 +468,7 @@ jobs:
name: "Release to Chocolatey"
runs-on: windows-latest
needs: [Setup, GitHubRelease]
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_Ring != 'Canary' ) && (needs.Setup.outputs.nkdAgility_HasChanged_src == 'true') }}
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_RunRelease == 'true' ) }}
steps:
- uses: actions/download-artifact@v4
with:
Expand All @@ -460,7 +492,7 @@ jobs:
name: "Release to Winget"
runs-on: windows-latest
needs: [Setup, GitHubRelease]
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_Ring != 'Canary' ) && (needs.Setup.outputs.nkdAgility_HasChanged_src == 'true') }}
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_RunRelease == 'true' ) }}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -481,7 +513,7 @@ jobs:
name: "Release to Docs"
runs-on: ubuntu-latest
needs: [Setup, BuildDocs, GitHubRelease]
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_Ring != 'Canary' ) && (needs.Setup.outputs.nkdAgility_HasChanged_docs == 'true') }}
if: ${{ success() && ( needs.Setup.outputs.nkdAgility_RunRelease == 'true' ) }}
steps:
- name: Download a single artifact
uses: actions/download-artifact@v4
Expand All @@ -491,17 +523,7 @@ jobs:
- name: "Find files"
shell: pwsh
run: |
Get-Item -Path .\
- name: "Folder Desider"
id: Folder-Decision
shell: pwsh
run: |
if ($Env:nkdAgility_Ring -ne 'Release') {
echo "subfolder=$Env:nkdAgility_Ring" >> $env:GITHUB_OUTPUT
Write-Output "subfolder=$Env:nkdAgility_Ring"
} else {
Write-Output "subfolder="
}
Get-Item -Path .\
- name: SFTP Upload ${{ (needs.Setup.outputs.nkdAgility_Ring) }}
uses: Dylan700/[email protected]
with:
Expand All @@ -513,6 +535,6 @@ jobs:
dry-run: ${{ (needs.Setup.outputs.nkdAgility_Ring) == 'Canary' }}
# A list of folders to upload in the format of `folder/ => upload_folder/`
uploads: |
./_site/ => ./azure-devops-migration-tools/${{ steps.Folder-Decision.outputs.subfolder }}
./_site/ => ${{needs.Setup.outputs.nkdAgility_DocsDeployFolder}}
# If true, any existing files in the remote upload directories are deleted.
delete: false
Loading