|
| 1 | +# Copyright (c) LieberLieber Software GmbH |
| 2 | +# This Source Code Form is subject to the terms of the Mozilla Public |
| 3 | +# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 | +# file, You can obtain one at https://mozilla.org/MPL/2.0/. |
| 5 | + |
| 6 | +name: Upload Architecture to Polarion |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + |
| 13 | +env: |
| 14 | + ModelName: LemonTree.DevOps.Demo.qeax |
| 15 | + ToolPolarionAutomationURL : https://www.lieberlieber.com/polarion/automation/latest/ |
| 16 | + PackageGuid: '{A7B2B212-BD09-483c-9946-ADD1417DE7CD}' #this is the package guid of the Architecture to export to Polarion |
| 17 | + |
| 18 | + # cached executable paths used by tool setup steps |
| 19 | + LTC_DIR: ${{ github.workspace }}\_toolcache\LTC |
| 20 | + SqliteToolsDir: ${{ github.workspace }}\_toolcache\sqlite-tools |
| 21 | + |
| 22 | +jobs: |
| 23 | + UploadArchitecture: |
| 24 | + defaults: |
| 25 | + run: |
| 26 | + shell: pwsh |
| 27 | + runs-on: [windows-latest] |
| 28 | + timeout-minutes: 15 |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v6.0.2 |
| 31 | + with: |
| 32 | + lfs: true |
| 33 | + fetch-depth: 0 |
| 34 | + |
| 35 | + |
| 36 | + - name: PrepareLTALicense #on the private runner LemonTree Automation is preinstalled. we just get the license |
| 37 | + run: | |
| 38 | + '${{secrets.LTALICENSE}}' | Out-File -FilePath lta.lic |
| 39 | +
|
| 40 | + # Custom action to setup LemonTree.Connect Automation that supports caching |
| 41 | + - name: Setup LemonTree.Connect |
| 42 | + uses: ./.github/actions/setup-ltc |
| 43 | + id: ltc_setup |
| 44 | + with: |
| 45 | + tool-url: ${{ env.ToolPolarionAutomationURL }} |
| 46 | + ltc-dir: ${{ env.LTC_DIR }} |
| 47 | + |
| 48 | + # Custom action to setup SQLite3 that supports caching |
| 49 | + - name: Setup SQLite3 |
| 50 | + uses: ./.github/actions/setup-sqlite |
| 51 | + with: |
| 52 | + sqlite-tools-dir: ${{ env.SqliteToolsDir }} |
| 53 | + |
| 54 | + - name: Extract LemonTree.Connect Mapping Configuration from Model |
| 55 | + id: extractMapping |
| 56 | + run: | |
| 57 | + # Query the model for the mapping configuration |
| 58 | + $query = "select notes from t_objectproperties where property = 'configuration' and object_id in (select object_id from t_object where ea_guid = '${{env.PackageGuid}}')" |
| 59 | + $mappingXml = & .\scripts\QueryModelSqliteExe.ps1 -Model "${{env.ModelName}}" -Query $query |
| 60 | + # Extract just the XML content (skip the script's info messages) |
| 61 | + $xmlContent = $mappingXml | Where-Object { $_ -match '<map' -or $_ -match '</' -or $_ -match '<[^>]+>' } | Out-String |
| 62 | + # Save to file |
| 63 | + $xmlContent | Out-File -FilePath "packagemapping.xml" -Encoding UTF8 |
| 64 | + Write-Output "Mapping file created: packagemapping.xml" |
| 65 | + $mappingPath = Resolve-Path "packagemapping.xml" |
| 66 | + Write-Output "MappingFile=$mappingPath" >> $env:GITHUB_OUTPUT |
| 67 | +
|
| 68 | + - name: Export Architecture to Polarion |
| 69 | + id: export_architecture |
| 70 | + run: | |
| 71 | + echo "Starting export of architecture to Polarion..." |
| 72 | + $exportOutput = &"${{steps.ltc_setup.outputs.tool-path}}" Export --Model "${{env.ModelName}}" --PackageGuid "${{env.PackageGuid}}" --Project "LT.Connect" --Mapping "${{steps.extractMapping.outputs.MappingFile}}" --ServerUrl "https://testdrive.polarion.com/polarion/" --Username "0ee265a99e504e639b4fe954739dd14e" --token "${{secrets.POLARIONTOKEN}}" --License "lta.lic" |
| 73 | + |
| 74 | + Write-Output "Export output:" |
| 75 | + Write-Output $exportOutput |
| 76 | + |
| 77 | + if ($LASTEXITCODE -eq 0) { |
| 78 | + Write-Output "message=:heavy_check_mark: Architecture successfully exported to Polarion" >> $env:GITHUB_OUTPUT |
| 79 | + Write-Output "export_status=success" >> $env:GITHUB_OUTPUT |
| 80 | + } else { |
| 81 | + Write-Output "::error::Architecture export to Polarion failed" |
| 82 | + Write-Output "message=:x: Architecture export failed, see [action log](${{env.GitHubProjectRoot}}/actions/runs/${{ github.run_id }}) for details" >> $env:GITHUB_OUTPUT |
| 83 | + Write-Output "export_status=failed" >> $env:GITHUB_OUTPUT |
| 84 | + exit 1 |
| 85 | + } |
| 86 | +
|
| 87 | + - name: Publish MD to Action Summary |
| 88 | + run: | |
| 89 | + $branch = git branch --show-current |
| 90 | + Write-Output "### Architecture Upload to Polarion - Branch: $branch :rocket:" >> $env:GITHUB_STEP_SUMMARY |
| 91 | + Write-Output "${{steps.export_architecture.outputs.message}}" >> $env:GITHUB_STEP_SUMMARY |
0 commit comments