Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/actions/check-solution-existence/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: check-solution-existence

description: check-solution-existence

inputs:
solution_name:
description: solution_name
required: true
environment_url:
description: environment_url
required: true
tenant_id:
description: tenant_id
required: true
client_id:
description: client_id
required: true
client_secret:
description: client_secret
required: true
secrets:
description: "environment secrets"
required: true

outputs:
solution_exists:
description: "solution existence flag"
value: ${{ steps.get-solutions-from-env.outputs.solution_exists }}

runs:
using: "composite"
steps:
- uses: Firenza/[email protected]
with:
secrets: ${{ inputs.secrets }}

- name: set-pac-path
uses: ./.github/actions/set-pac-path

# Use pac cli command to get the solutions list.
# This action is not implemented in GitHub Actions for Power Platform
- name: get-solutions-from-env
id: get-solutions-from-env
run: |
# Create a connection to the environment
$environment_url = "${{ inputs.environment_url }}"
$tenant_id = "${{ inputs.tenant_id }}"
$client_id = "${{ inputs.client_id }}"
$client_secret = "${{ inputs.client_secret }}"
pac auth create --url $environment_url --tenant $tenant_id --applicationId $client_id --clientSecret $client_secret

# List all the solutions on the environment
$result = pac solution list
$lines = $result | where{$_ -ne ""} | Select-Object -Skip 3
$solution_exists = $false

# Check if the solution unique name exists in the solution list
for ($i=0; $i -lt $lines.Length; $i++) {
while($lines[$i].Contains(" ")) {
$lines[$i] = $lines[$i].Replace(" ", " ")
}

$columns = $lines[$i] -split " "
if ($columns[2] -eq "${{ inputs.solution_name }}") {
$solution_exists = $true
break
}
}

# Return the flag
echo "::set-output name=solution_exists::$solution_exists"
shell: pwsh
21 changes: 21 additions & 0 deletions .github/actions/deploy-solution/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ inputs:
secrets:
description: "secrets"
required: true
solution_action:
description: "solution_action"
required: true
solution_exists:
description: "solution_exists"
default: "false"
required: false

runs:
using: "composite"
Expand Down Expand Up @@ -71,6 +78,8 @@ runs:

- name: import-solution-to-environment
uses: microsoft/powerplatform-actions/import-solution@latest
env:
import_as_holding: "${{ inputs.solution_action == 'upgrade' && inputs.solution_exists == 'True' }}"
with:
environment-url: ${{ inputs.environment_url }}
tenant-id: ${{ env.TENANT_ID }}
Expand All @@ -81,3 +90,15 @@ runs:
use-deployment-settings-file: true
deployment-settings-file: src/${{ inputs.solution_name }}/config/deploymentSettings.json
run-asynchronously: true
import-as-holding: ${{ env.import_as_holding }}

- name: upgrade-solution
uses: microsoft/powerplatform-actions/upgrade-solution@latest
with:
environment-url: ${{ inputs.environment_url }}
tenant-id: ${{ env.TENANT_ID }}
app-id: ${{ env.CLIENT_ID }}
client-secret: ${{ env.CLIENT_SECRET }}
solution-name: ${{ inputs.solution_name }}
async: true
if: ${{ inputs.solution_action == 'upgrade' && inputs.solution_exists == 'True' }}
24 changes: 24 additions & 0 deletions .github/workflows/build-deploy-solution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,32 @@ on:
environment:
required: true
description: "environment where the build will be deployed"
solution_action:
description: "update or upgrade the solution"
required: true
default: "upgrade"

jobs:
check-solution-existence:
runs-on: windows-2022
environment: ${{ github.event.inputs.environment }}
steps:
- uses: actions/checkout@v2
- id: check-solution
uses: ./.github/actions/check-solution-existence
with:
solution_name: ${{ secrets.SOLUTION_NAME }}
environment_url: ${{ secrets.ENVIRONMENT_URL }}
tenant_id: ${{ secrets.TENANT_ID }}
client_id: ${{ secrets.CLIENT_ID }}
client_secret: ${{ secrets.CLIENT_SECRET }}
secrets: ${{ toJSON(secrets) }}
outputs:
solution_exists: ${{ steps.check-solution.outputs.solution_exists }}

build-deploy-solution:
runs-on: ubuntu-latest
needs: check-solution-existence
name: deploy solution to ${{ github.event.inputs.environment }} environment
environment: ${{ github.event.inputs.environment }}
steps:
Expand Down Expand Up @@ -62,6 +84,8 @@ jobs:
solution_name: ${{ github.event.inputs.solution_name }}
environment: ${{ needs.get-subdomain.outputs.subdomain }}
secrets: ${{ toJSON(secrets) }}
solution_action: ${{ github.event.inputs.solution_action }}
solution_exists: ${{ needs.check-solution-existence.outputs.solution_exists }}

import-data-and-turn-on-flows:
runs-on: windows-2022
Expand Down