microsoft / microsoft/powerplatform-actions

Deployed solution does not contain the Model-driven App

Open
#263 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
301
Forks
88
PR merge metrics
No merged PRs in 30d

Description

Hi there.

I am using the power-platform actions to deploy solution between environments.

I have noticed that the solution is being deployed successfully, however on the target environment, the Model driven app is not there. There are all the objects that were in the DEV environment but on the TEST or PROD environment the MD app is missing.

Is this some kind of a limitation of these power-platform actions I am not aware of or is it a workflow's fault?

I am including on of the workflows that is responsible of deploying from DEV to TEST environment:

name: Deploy To Test Environment

# Currently triggering this workflow on custom events, using the api https://docs.github.com/en/rest/reference/repos#create-a-repository-dispatch-event
# Can be easily changed to other events https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
# NOTE: You have to change env variables with appropriate values, if you are modifying it.
on:
 repository_dispatch:
   types: [deploy_to_test]
        
jobs:
  build:

    env:
     solutionName: ${{ github.event.client_payload.solutionname }}
     branchName: ${{ github.event.client_payload.branch }}
     notes: ${{ github.event.client_payload.notes }}
     sourceEnvironmentUserId: ${{ github.event.client_payload.sourceenvironmentuserid }}
     sourceEnvironmentSecretName: ${{ github.event.client_payload.sourceenvironmentsecretname }}
     sourceEnvironmentUrl: ${{ github.event.client_payload.sourceenvironmenturl }}
     targetEnvironmentUserId: ${{ github.event.client_payload.targetenvironmentuserid }}
     targetEnvironmentSecretName: ${{ github.event.client_payload.targetenvironmentsecretname }}
     targetEnvironmentUrl: ${{ github.event.client_payload.targetenvironmenturl }}
     # build variable will go away once we use actions to create the environment
     buildEnvironmentUserId: ${{ github.event.client_payload.buildenvironmentuserid }}
     buildEnvironmentSecretName: ${{ github.event.client_payload.buildenvironmentsecretname }}
     buildEnvironmentUrl: ${{ github.event.client_payload.buildenvironmenturl }}
     requestId: ${{ github.event.client_payload.requestid }}
     projectId: ${{ github.event.client_payload.projectid }}

    runs-on: windows-latest

    steps:
    - name: 'Clone this repo'
      uses: actions/checkout@v3.1.0

    # Github api create-a-repository-dispatch-event doesn't allow more than 10 properties in the client_payload
    # Hence we are using a request object inside a client_payload to take additional properties.
    # This step can be ignored if using the workflow based on the default events.
    - name: 'Parsing the request from event client_payload'
      id: parse-client-payload-request
      run: |
        $requestPayload = echo "${{ github.event.client_payload.request }}"
        $requestPayloadObj = $requestPayload | ConvertFrom-Json
        $hashProperties = @{}
        foreach ($property in $requestPayloadObj.PSObject.Properties) {
          echo "$($property.Name) :: $($property.value)"
          $hashProperties[$property.Name] = $property.Value
        }

        echo "buildEnvironmentUserId=$($hashProperties.buildenvironmentuserid)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
        echo "buildEnvironmentSecretName=$($hashProperties.buildenvironmentsecretname)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
        echo "buildEnvironmentUrl=$($hashProperties.buildenvironmenturl)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
        echo "requestId=$($hashProperties.requestid)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
        echo "projectId=$($hashProperties.projectId)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
        echo "notes=$($hashProperties.notes)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append


    - name: 'Export the solution from Dev (source) environment'
      id: export-dev
      uses: microsoft/powerplatform-actions/export-solution@latest
   
      with:
        user-name: ${{ env.sourceEnvironmentUserId }}
        password-secret: ${{ secrets[env.sourceEnvironmentSecretName] }}
        solution-name: ${{ env.solutionName }}
        environment-url: ${{ env.sourceEnvironmentUrl }}
        solution-output-file: "${{ env.solutionName }}.zip"
        run-asynchronously: true
        
        

    - name: 'Unpack the exported solution'
      id: unpack-dev
      uses: microsoft/powerplatform-actions/unpack-solution@latest
      with:
        solution-file: "${{ env.solutionName }}.zip"
        solution-folder: "${{ env.solutionName }}"

    - name: 'Commit the unpacked solution to the topic branch'
      id: branch-solution
      uses: microsoft/powerplatform-actions/branch-solution@latest
      with:
       solution-folder: "${{ env.solutionName }}"
       solution-target-folder: "${{ env.solutionName }}"
       repo-token: ${{ secrets.GITHUB_TOKEN }}
       branch-name: ${{ env.branchName }}
       clobber-branch: true
       allow-empty-commit: true

    - name: 'Pack the solution for testing in build environment'
      id: pack-dev
      uses: microsoft/powerplatform-actions/pack-solution@latest
      with:
        solution-folder: ${{env.solutionName}}
        solution-file: "${{env.solutionName}}_Unmanaged.zip"

    - name: 'Import the solution to Build Environment'
      id: import-build
      uses: microsoft/powerplatform-actions/import-solution@latest
      with:
        environment-url: ${{env.buildEnvironmentUrl}}
        user-name: ${{env.buildEnvironmentUserId}}
        password-secret: ${{ secrets[env.buildEnvironmentSecretName] }}
        solution-file: "${{env.solutionName}}_Unmanaged.zip"
        run-asynchronously: true

    - name: 'Export the solution as managed from build environment'
      id: export-build
      uses: microsoft/powerplatform-actions/export-solution@latest
      with:
        user-name: ${{env.buildEnvironmentUserId}}
        password-secret: ${{ secrets[env.buildEnvironmentSecretName] }}
        solution-name: ${{ env.solutionName }}
        environment-url: ${{env.buildEnvironmentUrl}}
        managed: 'true'
        solution-output-file: "${{ env.solutionName }}_managed.zip"
        run-asynchronously: true

    - name: 'Import the managed solution to the Test (target) Environment'
      id: import-test
      uses: microsoft/powerplatform-actions/import-solution@latest
      with:
        environment-url: ${{ env.targetEnvironmentUrl }}
        user-name: ${{ env.targetEnvironmentUserId }}
        password-secret: ${{ secrets[env.targetEnvironmentSecretName] }}
        solution-file: "${{ env.solutionName }}_managed.zip"
        import-as-holding: true
        run-asynchronously: true
        
    - name: 'upgrade-solution'
      uses: microsoft/powerplatform-actions/upgrade-solution@latest
      with:
        environment-url: ${{ env.targetEnvironmentUrl }}
        user-name: ${{ env.targetEnvironmentUserId }}
        password-secret: ${{ secrets[env.targetEnvironmentSecretName] }}
        solution-name: ${{ env.solutionName }}
        async: true

    - name: 'Upload the managed solution to artifact'
      uses: actions/upload-artifact@v3
      with:
        name: ${{env.SolutionName}}
        path: "${{ env.solutionName }}_managed.zip"
     
    # Reading the different power platform action status to upload the status as artifact, to easily communicate it using other jobs.
    - name: Save job status to a file (status.json)
      if: always()
      run: |
        $errors=@{}
        function Process-StepOutputs($stepName, $outCome, $errorMessage) {
          if ($outcome -eq "success" -or $outcome -eq "skipped") {
            return ""
          } else {
            if ($null -ne $errorMessage -and $errorMessage -ne "") {
              $errors["$stepName"] = $errorMessage
            } else {
              $errors["$stepName"] = "Error occured in GitHub action $stepName"
            }
          }
        }

        $outCome = echo "${{ steps.export-dev.outcome }}"
        $errorMsg = echo "${{ steps.export-dev.outputs.errorMessage }}"
        Process-StepOutputs "export-dev" $outCome $errorMsg

        $outCome = echo "${{ steps.unpack-dev.outcome }}"
        $errorMsg = echo "${{ steps.unpack-dev.outputs.errorMessage }}"
        Process-StepOutputs "unpack-dev" $outCome $errorMsg

        $outCome = echo "${{ steps.pack-dev.outcome }}"
        $errorMsg = echo "${{ steps.pack-dev.outputs.errorMessage }}"
        Process-StepOutputs "pack-dev" $outCome $errorMsg

        $outCome = echo "${{ steps.import-build.outcome }}"
        $errorMsg = echo "${{ steps.import-build.outputs.errorMessage }}"
        Process-StepOutputs "import-build" $outCome $errorMsg

        $outCome = echo "${{ steps.export-build.outcome }}"
        $errorMsg = echo "${{ steps.export-build.outputs.errorMessage }}"
        Process-StepOutputs "export-build" $outCome $errorMsg

        $outCome = echo "${{ steps.import-test.outcome }}"
        $errorMsg = echo "${{ steps.import-test.outputs.errorMessage }}"
        Process-StepOutputs "import-test" $outCome $errorMsg

        $jobStatus = echo ${{ job.status }}
        $workflow = echo ${{ github.workflow }}
        $branch = echo ${{ env.branchName }}
        $repo = echo ${{ github.repository }}
        $run = echo ${{ github.run_id }}
        $requestId = echo "${{env.requestId}}"
        $projectid = echo "${{env.projectId}}"
        $errorStr = ConvertTo-Json -InputObject $errors
         $status = @{
          'status' = $jobStatus;
          'workflow' = "$workflow";
          'branch' = $branch;
          'repo' = $repo;
          'run' = $run;
          'requestid' = $requestId;
          'projectid' = "$projectid";
          'errors'= "$errorStr"
        }

        $jsonString = ConvertTo-Json -InputObject $status
        $jsonString > status.json

    - name: Upload job status file as artifact
      if: always()
      uses: actions/upload-artifact@v3
      with:
        name: job_status
        path: status.json

  # This job is to notify the webhook url when the workflow is triggered on the custom event and the payload has the webhook url.
  # Otherwise this job can be ignored.
  notify:
    needs: [build]
    if: always()
    runs-on: windows-latest
    steps:

    - name: Download artifact job_status
      uses: actions/download-artifact@v1
      with:
        name: job_status
      continue-on-error: true

    - name: Reading status & Invoking the webhook
      if: always()
      run: |
        $fileExists = Test-Path job_status/status.json -PathType Leaf
        $uri = echo '${{ github.event.client_payload.webhookurl }}'
        $jsonData = ''
        if ($fileExists) {
          $jsonData = Get-Content job_status/status.json
          echo "Data read from status file :: " $jsonData
        } else {
          $workflow = echo ${{ github.workflow }}
          $branch = echo ${{ github.event.client_payload.branch }}
          $repo = echo ${{ github.repository }}
          $run = echo ${{ github.run_id }}
          $requestId = echo "${{env.requestId}}"
        $projectid = echo "${{env.projectId}}"
          $errors = @{
            "Actions"="Unable to get the status file from the previous job"
          }
          $status = @{
            'status' = "$fileExists";
            'workflow' = "$workflow";
            'branch' = $branch;
            'repo' = $repo;
            'run' = $run;
            'requestid' = $requestId;
            'projectid' = "$projectid";
            'errors' = "$errors"
          }
          $jsonData = ConvertTo-Json -InputObject $status
          echo "Data constructed as status.json file is not present :: " $jsonData
        }
        echo "Invoking the WebHook Url"
        Invoke-RestMethod -Uri $uri -Body $jsonData  -Method POST -ContentType 'application/json'
        echo "Invoked the WebHook Url"

We will be rebuilding our custom ALM App to use Pipelines in the Q2 2023, but for now I'd like to figure out what's the reason that Model-Driven apps are not being deployed.

Thank you.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the GitHub Actions logs for export-dev, import-build, export-build, import-test, and upgrade-solution, then inspect the solution archive produced between those steps. Compare the solution contents in DEV, build, and TEST, especially the model-driven app; done means the app is present in the target after the workflow completes and the responsible step or limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, typescript
Domain
ci-cd, cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.