Automating Power Platform solution deployment with GitHub Actions

26th July 2023

Hello friends! I’m back with another post on GitHub actions, where in this post, we’ll take a look at how to automate a solution deployment! If you didn’t check out yesterdays post on an introduction to GitHub Actions for working with Power Platform, including how to use secrets in GitHub, check out the post below…

New workflow

So lets jump into a repository in GitHub and create a new actions workflow!

Start by adding the following into your yml file.

name: export-and-import-solution
# Export solution from DEV environment and import to test

      # Change this value
        description: 'name of the solution to worked on from Power Platform'
        required: true
        default: ALMLab
       #Do Not change these values
        description: 'folder name for staging the exported solution *do not change*'
        required: true
        default: out/exported/

In the above yml we gave our workflow a name, set the trigger for the workflow and then added some parameters.

Now we will add some connection variables using the following:

#edit your values here
  contents: write

In the above replace all of the environment values for each property. So enter your dev environment values and test environment values. If you’re deploying to a build or prod environment feel free to change the names of the test properties.

Now we will add our job and its tasks with the following code.

    runs-on: windows-latest
    # or you can say runs-on: ubuntu-latest

    - uses: actions/checkout@v2
        lfs: true

    - name: export-solution action
      uses: microsoft/powerplatform-actions/export-solution@v0
        environment-url: ${{env.DEV_ENVIRONMENT_URL}}
        app-id: ${{env.DEV_CLIENT_ID}}
        client-secret: ${{ secrets.Dev_Environment_Application_Secret }}
        tenant-id: ${{env.DEV_TENANT_ID}}
        solution-name: ${{ github.event.inputs.solution_name }}
        solution-output-file: ${{ github.event.inputs.solution_exported_folder}}/${{ github.event.inputs.solution_name }}.zip

    - name: Import solution to test env
      uses: microsoft/powerplatform-actions/import-solution@v0
        environment-url: ${{env.TEST_ENVIRONMENT_URL}}
        app-id: ${{env.TEST_CLIENT_ID}}
        client-secret: ${{ secrets.Test_Environment_Application_Secret }}
        tenant-id: ${{env.TEST_TENANT_ID}}
        solution-file: ${{ github.event.inputs.solution_exported_folder}}/${{ github.event.inputs.solution_name }}.zip
        force-overwrite: true
        publish-changes: true

In the above yml, replace the values following secrets. in each part of the code with the relevant secret you need to use to connect to that environment. So in the export solution action, reference your source environment application secret and then in the import solution reference your target environment application secret.

You need to have added your secrets in the repository settings first, which you’ll find help for in this post…

Save and test

Now select that green commit changes button and head to the actions tab again in your repository. Now select to run the workflow and provide a name of a solution which you have in the source environment that you want to import to the target and simply select run workflow.

Now I’ll take a look at my workflow run and as you can see my solution has been deployed!

Upcoming content 📝

Make sure you’re subscribed so you don’t miss my upcoming content on working with GitHub actions to achieve CI/CD automation scenarios for working with Power Platform! I’ve still got a bunch of posts to come covering all sorts of workflows you can achieve using the actions for Power Platform! 📩

Posted in Power Platform Dev Tools, ALM
  • Nigel Price

    Hi Lewis How about a blog about best practise for co-authoring canvas PowerApps ?

    10:28 pm 26th July 2023 Reply
    • Hey Nigel!

      I’ll definitely think about this. It’s a topic I still need to make my own decisions about really. I’m not completely decided on the best way to go about it i.e. using the canvas apps co-authoring functionality, using model-driven apps with custom pages and assigning devs to a page at a time and working that with source control, or other methods! I’ll for sure have a think and write a post following the current series on the Developer Tools 🙂

      1:22 pm 27th July 2023 Reply

Leave a Reply

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

This will close in 0 seconds