|
| 1 | +name: 'Build via AzDO' |
| 2 | + |
| 3 | +inputs: |
| 4 | + artifact-name: |
| 5 | + description: Output artifact name |
| 6 | + default: azdo-artifact |
| 7 | + type: string |
| 8 | + |
| 9 | + branch-name: |
| 10 | + description: Branch name |
| 11 | + default: main |
| 12 | + type: string |
| 13 | + |
| 14 | + # dist-tag: |
| 15 | + # description: Dist-tag |
| 16 | + # default: main |
| 17 | + # type: string |
| 18 | + |
| 19 | + # version: |
| 20 | + # description: Version |
| 21 | + # required: true |
| 22 | + # type: string |
| 23 | + |
| 24 | +outputs: |
| 25 | + version: |
| 26 | + description: Version |
| 27 | + value: ${{ jobs.download-pipeline-artifact.outputs.version }} |
| 28 | + |
| 29 | + version-type: |
| 30 | + description: Version |
| 31 | + value: ${{ jobs.download-pipeline-artifact.outputs.version-type }} |
| 32 | + |
| 33 | +defaults: |
| 34 | + run: |
| 35 | + shell: bash |
| 36 | + |
| 37 | +env: |
| 38 | + AZDO_ORG: ${{ vars.AZDO_ORG }} |
| 39 | + AZDO_PIPELINE_NAME: ${{ vars.AZDO_PIPELINE_NAME }} |
| 40 | + AZDO_PROJECT: ${{ vars.AZDO_PROJECT }} |
| 41 | + AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }} |
| 42 | + AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }} |
| 43 | + AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }} |
| 44 | + |
| 45 | +runs: |
| 46 | + using: composite |
| 47 | + steps: |
| 48 | + - uses: azure/login@v2 |
| 49 | + with: |
| 50 | + allow-no-subscriptions: true |
| 51 | + client-id: ${{ env.AZURE_CLIENT_ID }} |
| 52 | + tenant-id: ${{ env.AZURE_TENANT_ID }} |
| 53 | + |
| 54 | + # - id: run-pipeline |
| 55 | + # uses: azure/cli@v2 |
| 56 | + # with: |
| 57 | + # inlineScript: | |
| 58 | + # set -e -o pipefail |
| 59 | + |
| 60 | + # az extension add --name azure-devops --only-show-errors |
| 61 | + # # az pipelines list --org ${{ env.AZDO_ORG }} --project ${{ env.AZDO_PROJECT }} |
| 62 | + # OUTPUT=$( |
| 63 | + # az pipelines run \ |
| 64 | + # --detect false --output json) \ |
| 65 | + # --name ${{ env.AZDO_PIPELINE_NAME }} \ |
| 66 | + # --org ${{ env.AZDO_ORG }} \ |
| 67 | + # --project ${{ env.AZDO_PROJECT }} \ |
| 68 | + # --variable ProjectBranch=${{ inputs.branch-name }} |
| 69 | + # ) |
| 70 | + |
| 71 | + # RUN_ID=$(echo "$OUTPUT" | jq -r '.id') |
| 72 | + # RUN_URL=$(echo "$OUTPUT" | jq -r '.url') |
| 73 | + |
| 74 | + # if [ -z "$RUN_ID" ] || [ "$RUN_ID" = "null" ]; then |
| 75 | + # echo "$OUTPUT" |
| 76 | + # echo "Failed to extract run ID from output" |
| 77 | + # exit 1 |
| 78 | + # fi |
| 79 | + |
| 80 | + # if [ -z "$RUN_URL" ] || [ "$RUN_URL" = "null" ]; then |
| 81 | + # echo "$OUTPUT" |
| 82 | + # echo "Failed to extract run URL from output" |
| 83 | + # exit 1 |
| 84 | + # fi |
| 85 | + |
| 86 | + # echo "run-id=$RUN_ID" | tee --append $GITHUB_OUTPUT |
| 87 | + # echo "url=$RUN_URL" | tee --append $GITHUB_OUTPUT |
| 88 | + |
| 89 | + # Temporarily not running pipeline but getting from existing result |
| 90 | + - id: run-pipeline |
| 91 | + name: Run pipeline |
| 92 | + run: | |
| 93 | + echo run-id=422059 | tee --append $GITHUB_OUTPUT |
| 94 | + echo url=https://fuselabs.visualstudio.com/531382a8-71ae-46c8-99eb-9512ccb91a43/_apis/build/Builds/422059 | tee --append $GITHUB_OUTPUT |
| 95 | +
|
| 96 | + - name: Wait for pipeline completion |
| 97 | + uses: azure/cli@v2 |
| 98 | + with: |
| 99 | + inlineScript: | |
| 100 | + set -e -o pipefail |
| 101 | +
|
| 102 | + az extension add --name azure-devops --only-show-errors |
| 103 | +
|
| 104 | + RUN_ID="${{ needs.run-pipeline.outputs.run-id }}" |
| 105 | + echo "Waiting for run ID: $RUN_ID to complete..." |
| 106 | +
|
| 107 | + # Timeout after 45 minutes (2700 seconds) |
| 108 | + TIMEOUT=2700 |
| 109 | + ELAPSED=0 |
| 110 | + INTERVAL=5 |
| 111 | +
|
| 112 | + while [ $ELAPSED -lt $TIMEOUT ]; do |
| 113 | + OUTPUT=$(az pipelines runs show --id "$RUN_ID" --org ${{ env.AZDO_ORG }} --project ${{ env.AZDO_PROJECT }} --detect false --output json) |
| 114 | + STATUS=$(echo "$OUTPUT" | jq -r '.status') |
| 115 | +
|
| 116 | + if [ -z "$STATUS" ] || [ "$STATUS" = "null" ]; then |
| 117 | + echo "Failed to extract status from output" |
| 118 | + exit 1 |
| 119 | + fi |
| 120 | +
|
| 121 | + echo "Current status: $STATUS (elapsed: ${ELAPSED}s)" |
| 122 | +
|
| 123 | + # Check for terminal states |
| 124 | + if [ "$STATUS" = "completed" ]; then |
| 125 | + echo "Pipeline completed!" |
| 126 | + RESULT=$(echo "$OUTPUT" | jq -r '.result') |
| 127 | + echo "Result: $RESULT" |
| 128 | +
|
| 129 | + if [ "$RESULT" != "succeeded" ]; then |
| 130 | + echo "Pipeline failed with result: $RESULT" |
| 131 | + exit 1 |
| 132 | + fi |
| 133 | +
|
| 134 | + echo "Pipeline succeeded!" |
| 135 | + exit 0 |
| 136 | + elif [ "$STATUS" = "canceling" ] || [ "$STATUS" = "canceled" ]; then |
| 137 | + echo "Pipeline was canceled" |
| 138 | + exit 1 |
| 139 | + fi |
| 140 | +
|
| 141 | + sleep $INTERVAL |
| 142 | + ELAPSED=$((ELAPSED + INTERVAL)) |
| 143 | + done |
| 144 | +
|
| 145 | + echo "Timeout reached after ${TIMEOUT} seconds for run ID: $RUN_ID" |
| 146 | + exit 1 |
| 147 | +
|
| 148 | + - name: Download artifact from Azure DevOps |
| 149 | + uses: azure/cli@v2 |
| 150 | + with: |
| 151 | + inlineScript: | |
| 152 | + set -e -o pipefail |
| 153 | +
|
| 154 | + tdnf install -y icu |
| 155 | + tdnf install -y jq |
| 156 | + az extension add --name azure-devops --only-show-errors |
| 157 | +
|
| 158 | + RUN_ID="${{ needs.run-pipeline.outputs.run-id }}" |
| 159 | + echo "Downloading artifact 'drop_build_main' from run ID: $RUN_ID" |
| 160 | +
|
| 161 | + # Create directory for artifact |
| 162 | + mkdir -p ./artifact-download/ |
| 163 | +
|
| 164 | + # Download the artifact |
| 165 | + az pipelines runs artifact download \ |
| 166 | + --artifact-name "drop_build_main" \ |
| 167 | + --detect false \ |
| 168 | + --org ${{ env.AZDO_ORG }} \ |
| 169 | + --path "$GITHUB_WORKSPACE/artifact-download/" \ |
| 170 | + --project ${{ env.AZDO_PROJECT }} \ |
| 171 | + --run-id "$RUN_ID" |
| 172 | +
|
| 173 | + # Verify artifact was downloaded |
| 174 | + if [ -z "$(ls -A artifact-download)" ]; then |
| 175 | + echo "Artifact directory is empty after download" |
| 176 | + exit 1 |
| 177 | + fi |
| 178 | +
|
| 179 | + echo "Artifact downloaded successfully" |
| 180 | +
|
| 181 | + - name: Upload artifact |
| 182 | + uses: actions/upload-artifact@v6 |
| 183 | + with: |
| 184 | + name: drop_build_main |
| 185 | + path: ./artifact-download/ |
| 186 | + |
| 187 | + - id: get-version |
| 188 | + name: Get version |
| 189 | + run: | |
| 190 | + VERSION=$(tar -xzOf botframework-webchat-core-*.tgz package/package.json) |
| 191 | +
|
| 192 | + echo version=$VERSION | tee --append $GITHUB_OUTPUT |
| 193 | +
|
| 194 | + if [[ "$VERSION" == *-0 ]]; then echo version-type=prerelease | tee --append $GITHUB_OUTPUT; else echo version-type=production | tee --append $GITHUB_OUTPUT; fi |
| 195 | + working-directory: ./artifact-download/tgzfiles |
| 196 | + |
| 197 | +# prepare-release: |
| 198 | +# name: Prepare release |
| 199 | +# needs: |
| 200 | +# - upload-pipeline-artifact |
| 201 | +# outputs: |
| 202 | +# prerelease: ${{ steps.save-version.outputs.prerelease }} |
| 203 | +# version: ${{ steps.save-version.outputs.version }} |
| 204 | +# permissions: |
| 205 | +# actions: read |
| 206 | +# contents: read |
| 207 | +# id-token: write |
| 208 | +# runs-on: ubuntu-latest |
| 209 | + |
| 210 | +# steps: |
| 211 | +# - uses: actions/checkout@v6 |
| 212 | +# - uses: actions/setup-node@v6 |
| 213 | + |
| 214 | +# - name: Download build artifact |
| 215 | +# uses: actions/download-artifact@v7 |
| 216 | +# with: |
| 217 | +# name: drop_build_main |
| 218 | +# path: ./azdo-artifact/ |
| 219 | + |
| 220 | +# - name: Prepare CDN artifact |
| 221 | +# run: | |
| 222 | +# mkdir -p ./github-artifact/cdn/ |
| 223 | +# cd ./github-artifact/cdn/ |
| 224 | +# unzip ../../azdo-artifact/cdn_files/CdnFilesUpload.zip |
| 225 | + |
| 226 | +# - name: Upload CDN artifact |
| 227 | +# uses: actions/upload-artifact@v6 |
| 228 | +# with: |
| 229 | +# name: asset-cdn |
| 230 | +# path: ./github-artifact/cdn/ |
| 231 | + |
| 232 | +# - name: Prepare tarball artifact |
| 233 | +# run: | |
| 234 | +# mkdir -p ./github-artifact/tarball/ |
| 235 | +# cd ./github-artifact/tarball/ |
| 236 | +# cp ../../azdo-artifact/tgzfiles/* . |
| 237 | + |
| 238 | +# - name: Upload tarball artifact |
| 239 | +# uses: actions/upload-artifact@v6 |
| 240 | +# with: |
| 241 | +# name: asset-tarball |
| 242 | +# path: ./github-artifact/tarball/ |
| 243 | + |
| 244 | +# - id: save-version |
| 245 | +# name: Save version |
| 246 | +# run: | |
| 247 | +# version=$(cat version.txt) |
| 248 | + |
| 249 | +# prerelease=$([[ "$version" == *-* ]] && echo true || echo false) |
| 250 | + |
| 251 | +# echo prerelease="$prerelease" | tee --append $GITHUB_OUTPUT |
| 252 | +# echo version="$version" | tee --append $GITHUB_OUTPUT |
| 253 | +# working-directory: ./azdo-artifact/version/ |
| 254 | + |
| 255 | +# - name: Prepare release notes |
| 256 | +# run: | |
| 257 | +# cp ./.github/release_notes_template.md ./release_notes.md |
| 258 | + |
| 259 | +# node \ |
| 260 | +# --eval "import fs from 'node:fs'; fs.writeFileSync(process.argv[1], fs.readFileSync(process.argv[1], 'utf8').replaceAll(process.argv[2], process.argv[3]));" \ |
| 261 | +# --input-type=module \ |
| 262 | +# -- \ |
| 263 | +# ./release_notes.md \ |
| 264 | +# {{webchat-js-integrity}} \ |
| 265 | +# "sha384-$(openssl dgst -sha384 -binary ./github-artifact/cdn/webchat.js | openssl base64 -A)" |
| 266 | + |
| 267 | +# node \ |
| 268 | +# --eval "import fs from 'node:fs'; fs.writeFileSync(process.argv[1], fs.readFileSync(process.argv[1], 'utf8').replaceAll(process.argv[2], process.argv[3]));" \ |
| 269 | +# --input-type=module \ |
| 270 | +# -- \ |
| 271 | +# ./release_notes.md \ |
| 272 | +# {{webchat-minimal-js-integrity}} \ |
| 273 | +# "sha384-$(openssl dgst -sha384 -binary ./github-artifact/cdn/webchat-minimal.js | openssl base64 -A)" |
| 274 | + |
| 275 | +# node \ |
| 276 | +# --eval "import fs from 'node:fs'; fs.writeFileSync(process.argv[1], fs.readFileSync(process.argv[1], 'utf8').replaceAll(process.argv[2], process.argv[3]));" \ |
| 277 | +# --input-type=module \ |
| 278 | +# -- \ |
| 279 | +# ./release_notes.md \ |
| 280 | +# {{version}} \ |
| 281 | +# "${{ steps.save-version.outputs.version }}" |
| 282 | + |
| 283 | +# cat ./release_notes.md |
| 284 | + |
| 285 | +# - name: Upload release notes |
| 286 | +# uses: actions/upload-artifact@v6 |
| 287 | +# with: |
| 288 | +# name: release-notes |
| 289 | +# path: ./release_notes.md |
| 290 | + |
| 291 | +# create-release: |
| 292 | +# name: Create release |
| 293 | +# needs: |
| 294 | +# - prepare-release |
| 295 | +# outputs: |
| 296 | +# release-tag: ${{ steps.create-release.outputs.release-tag }} |
| 297 | +# permissions: |
| 298 | +# contents: write |
| 299 | +# runs-on: ubuntu-latest |
| 300 | + |
| 301 | +# steps: |
| 302 | +# - name: Download release notes |
| 303 | +# uses: actions/download-artifact@v7 |
| 304 | +# with: |
| 305 | +# name: release-notes |
| 306 | +# path: release-notes |
| 307 | + |
| 308 | +# - env: |
| 309 | +# GH_TOKEN: ${{ github.token }} |
| 310 | +# id: create-release |
| 311 | +# name: Create release |
| 312 | +# run: | |
| 313 | +# if [[ "${{ needs.prepare-release.outputs.prerelease }}" == "true" ]]; then prerelease=1; fi |
| 314 | + |
| 315 | +# release_tag=v${{ needs.prepare-release.outputs.version }} |
| 316 | + |
| 317 | +# gh release create $release_tag \ |
| 318 | +# --draft \ |
| 319 | +# --notes-file ./release-notes/release_notes.md \ |
| 320 | +# ${prerelease:+--prerelease} \ |
| 321 | +# --repo ${{ github.repository }} \ |
| 322 | +# --target ${{ github.ref }} |
| 323 | + |
| 324 | +# echo release-tag=$release_tag | tee --append $GITHUB_OUTPUT |
| 325 | + |
| 326 | +# upload-release-asset: |
| 327 | +# name: Upload release asset |
| 328 | +# needs: |
| 329 | +# - create-release |
| 330 | +# permissions: |
| 331 | +# contents: write |
| 332 | +# runs-on: ubuntu-latest |
| 333 | + |
| 334 | +# steps: |
| 335 | +# - name: Download asset artifact |
| 336 | +# uses: actions/download-artifact@v7 |
| 337 | +# with: |
| 338 | +# merge-multiple: true |
| 339 | +# path: ./asset/ |
| 340 | +# pattern: asset-* |
| 341 | + |
| 342 | +# - env: |
| 343 | +# GH_TOKEN: ${{ github.token }} |
| 344 | +# name: Upload assets |
| 345 | +# run: | |
| 346 | +# gh release upload ${{ needs.create-release.outputs.release-tag }} \ |
| 347 | +# ./asset/* \ |
| 348 | +# --repo ${{ github.repository }} |
| 349 | + |
| 350 | +# - env: |
| 351 | +# GH_TOKEN: ${{ github.token }} |
| 352 | +# name: Publish release |
| 353 | +# run: | |
| 354 | +# gh release edit ${{ needs.create-release.outputs.release-tag }} \ |
| 355 | +# --draft=false \ |
| 356 | +# --repo ${{ github.repository }} |
0 commit comments