Power Platform Actions for GitHub are a powerful way to implement DevOps and ALM strategies in your Power Platform deployments. In this post, we will take a look at these GitHub actions, and go through how we can use them in a real-world situation, by connecting to a Power Platform model-driven app and deploy the code from one environment to another.
The Power Platform Actions for GitHub can be found in this repo here on Microsoft’s GitHub – https://github.com/microsoft/powerplatform-actions. Note the documentation states “PRE-RELEASE SOFTWARE. The software is a pre-release version. It may not work the way a final version of the software will. We may change it for the final, commercial version. We also may not release a commercial version”:
First, in the Power Apps Maker, let’s create a new solution:
We will call it My Test Solution (MyTestSolution):
And we will add the Account table/entity:
And we will add a new column:
First, let’s create a new GitHub repo. We will call it PowerPlatformTest. I will make mine private in this case:
Let’s first create a GitHub Secret to hold our Power Platform source password. That way we won’t need to expose it in the workflow we will create shortly:
In my example, I will deploy from one source environment to another target environment. These systems will have different usernames and passwords. You may have the same username and password in your case.
Give the secret a name, e.g. POWERPLATFORM_SOURCEPASSWORD, enter in the password in the value, and click Add Secret:
I will create a 2nd secret for the POWERPLATFORM_TARGETPASSWORD:
Now let’s set up a new workflow. Click on Actions, and select set up a workflow yourself:
We will change the workflow to run from the default ubuntu-latest to windows-latest:
Now let’s run some steps. We will create steps to export the solution from our source environment, import it into a target environment, then publish the target environment.
Let’s add a step at the bottom of the file to first export our solution. Note the uses notation is microsoft/powerplatform-actions/export-solution@v0. We are basically calling the action from the microsoft/powerplatform-actions repository to export. Note how we are providing the Power Platform URL and authentication:
– name: Export Solution
uses: microsoft/powerplatform-actions/export-solution@v0
with:
environment-url: https://yourorg.crm.dynamics.com
user-name: admin@yourorg.onmicrosoft.com
password-secret: ${{ secrets.POWERPLATFORM_SOURCEPASSWORD }}
solution-name: MyTestSolution
solution-output-file: ‘MyTestSolution.zip’
The notation of what to put here is in each of the folders on the Power Platform actions page:
Let’s commit the new file and see it run:
Now, let’s look at the action running:
Clicking on Export Solution, we see we have successfully connected to the org and the run has worked:
And the solution is exported to:
Now let’s add some more actions. We will add an action to import into our target org:
– name: Import Solution
uses: microsoft/powerplatform-actions/import-solution@v0
with:
environment-url: https://yourtargetorg.crm.dynamics.com
user-name: admin@yourtargetorg.onmicrosoft.com
password-secret: ${{ secrets.POWERPLATFORM_TARGETPASSWORD }}
solution-file: ‘MyTestSolution.zip’
And let’s run publish-solution. Note here I am accessing the action from @main instead of @version. I had trouble running the @version, so used @main instead:
– name: Publish Solution
uses: microsoft/powerplatform-actions/publish-solution@main
with:
environment-url: https://yourtargetorg.crm.dynamics.com
user-name: admin@yourtargetorg.onmicrosoft.com
password-secret: ${{ secrets.POWERPLATFORM_TARGETPASSWORD }}
The file should now look something like:
On running this, we see the output of our newly added actions, first Import:
Then Publish:
And if we log into our target org, we see the test solution has been imported:
Now we have a workflow set up so any time code is checked into the main branch, we will export the solution and import it into our target org. There are several other features with the Power Platform action for GitHub, which I’ll write about in future posts, including:
- Unpacking, packing, cloning, branching, upgrading solutions
- Restoring, resetting, copying, creating, deleting environments
I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.
IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.
THANK YOU, AND LET’S KEEP LEARNING TOGETHER.
CARL