Have you used a deployment settings file in an Azure Pipeline before with the Power Platform Build Tools where it’s quite easy to notice the input for this to resolve your connection references, and update environment variable values?
But what about the world of GitHub actions where we simply use yml to build our workflow, rather than a GUI with easy input boxes that point out the tools we can use? Well, I’m here to share that using a deployment settings file with the import solution action in GitHub Actions for Power Platform, is absolutely possible, and in this post, we’ll look at how to achieve the use of this in a deployment workflow! 😎
Create the deployment settings file
So the first thing we need to do, is create our deployment settings file. We will use a template for this, and then we’ll add in all of the connection references in our solution that will need resolving when they get to our target environment, as well as all of the environment variables that will need updating.
Then we will populate each of the connection references in our file with connection id’s from our target environment which will support the connection references being imported. We will also provide values for all of the environment variables in the file which we have added. These values should be the values that should be applied in our target environment.
Template
So, here is the template we will use and then populate.
{
"EnvironmentVariables": [
{
"SchemaName": "variable_schema_name",
"Value": ""
}
],
"ConnectionReferences": [
{
"LogicalName": "connection_reference_logical_name",
"ConnectionId": "target_environment_connection_id",
"ConnectorId": "connector_id"
}
]
}
So above, you’ll notice I have a single object, with two nested arrays, one for my environment variables, and one for my connection references. Simply add additional objects copying the existing one in each array depending on your requirements / how many environment variables and connection references you have.
Save the deployment settings file
Now I need to save my deployment settings file in a location that my GitHub actions workflow can retrieve my file from. I’m going to put this in my GitHub repository that my workflow is in.
![](https://www.lewisdoes.dev/content/images/wp-content/uploads/2023/07/screenshot-2023-07-29-at-21.35.12.png)
Reference the deployment settings file
Now very simply let’s head to a GitHub Actions workflow which uses an import-solution task to import a solution to one of our Power Platform environments. I’m going to use the workflow I created in this post.
We’ll need to open up the workflow in the code tab to edit it to start with…
Here is my import solution task…
- name: Import solution to test env
uses: microsoft/powerplatform-actions/import-solution@v0
with:
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
All I am going to do here is add two additional inputs within the ‘with’, which are the following:
use-deployment-settings-file: true
deployment-settings-file: DeploymentSettings.json
To reference a file saved in your repository at the top level simply provide its name as I have done above.
You may also want to make this a dynamic value fetched from an input from triggering the workflow if you’re using a manual trigger. To do this you can add an additional input similar to the one below for the solution name to your workflow, and then reference this in your deployment-settings-file parameter.
inputs:
# Change this value
solution_name:
description: 'name of the solution to worked on from Power Platform'
required: true
default: ALMLab
Testing it out
Now let’s test things out and see how they go!
The first thing we have is a successful workflow run…
![](https://www.lewisdoes.dev/content/images/wp-content/uploads/2023/07/screenshot-2023-07-29-at-22.08.37.png)
And now I also have my solution in Power Apps with environment variables populated and connection references resolved to the connections in my test environment! ✅
![](https://www.lewisdoes.dev/content/images/wp-content/uploads/2023/07/screenshot-2023-07-29-at-22.09.00.png)
Mission accomplished! 🫶
Upcoming content
Make sure you’re subscribed to my blog to get all of my upcoming content on the Power Platform Developer Tools! In my next post we’ll be looking at how to diagnose and resolve unexpected errors when using the Power Platform CLI, Build Tools, or GitHub Actions to import a solution. Stay tuned! 📩
Subscribe