Amazon.co.uk Widgets

Log in

X

Automate the publication of your Power Platform solution via GitHub

This article is Publish Power Apps securely via GitHub part 3. You'll need to have completed Publish Power Apps securely via GitHub (part 1) and Publish Power Apps securely via GitHub (part 2) and before continuing. This article deals with the GitHub setup and workflow required to deploy a Power Platform app via GitHub thus providing a recognisable governance and software assurance methodology for your Power Platform apps.

Pre-requisites

In order to complete this you will need a GitHub account.

Create a repository

  • Click "+" then New Repository" 
  • Give your repository a name, I made mine public and you can find it here, YMMV. Add a README and choose a license. I chose MIT License.
Creating a GitHub repository
Creating a GitHub repository

Create a new secrets for Service Principal Authentication

  • In Settings, Security, Secrets and variables, choose Actions.
  • On the resulting "Actions secrets and variables" page create a new repository secret.
  • Name them "POWERPLATFORMSPN, POWER_YOURNAME_DEV, POWER_YOURNAME_TRIAL and POWER_YOURCOMPANY_DEFAULT"
  • Paste the client secret values you created for each of them in Azure Active Directory (AAD) and saved away somewhere safe back in part one of this series of articles and then select Add secret. These client secrets are the key to connecting the Power Apps solutions with GitHub.
Adding a GitHub repository secret from Azure Active Directory (AAD)
Adding a GitHub repository secret from Azure Active Directory (AAD)

Create a GitHub Action to export and unpack the solution to a new branch in your GitHub repository

  • Click "Actions" and choose "Simple workflow"
  • Delete the content and paste the content of export-and-branch-solution-with-spn-auth.yml from the Microsoft Power Platform GitHub Actions Lab repository.
  • Rename the file from "blank.yml" to "export-and-branch-solution.yml".
  • Update <ENVIRONMENTURL> with the URL for the development environment you want to export from e.g. "c0ffee.crm.dynamics.com" To find it run one of the power apps and grab it from the URL bar in the browser.
  • Then update <APPID> and <TENANT ID> with the values you saved away somewhere safe back in part one of this series of articles 
Create a GitHub Action using the workflow from the Power Platform actions lab
Create a GitHub Action using the workflow from the Power Platform actions lab

Commit the changes to GitHub

  • Now commit the changes and your workflow is created
Committing the GitHub action
Committing the GitHub action

GitHub Action created

GitHub action created
GitHub action created

Test the GitHub Action

Run the workflow

  • Navigate to "Actions - Run Workflow and set the name of the solution to whatever you chose and then click "Run workflow"
Run Workflow in GitHub actions
Run Workflow in GitHub actions
  • Wait for the workflow to start and you can select it to watch its progress. There will be a lot of information and you can use it to debug your workflow if necessary Once it completes all the stages you will see a summary.
Monitoring your running workflow in GitHub actions
Monitoring your running workflow in GitHub actions

Check the branch was created and merge it to your main branch

  • Navigate to "Code" and select the branch the action just (hopefully) created.
  • Confirm that your solution is visible in the solutions/name folder.
Power Platform Solutions branch in GitHub repository
Power Platform Solutions branch in GitHub repository
  • Click Contribute and "Open pull request", you should see that there are no conflicts with our main branch. it only has a README after all.
Open a pull request
Open a pull request
  • Create the pull request
Create a pull request
Create a pull request
  • Click "Merge pull request". (Make sure it Merge commit is selected).
  • You may have ALM policies for how you manage merges and they can be respected by having rules here.
Merge the pull request
Merge the pull request
  • Delete the branch as it is now no longer required.
Delete the branch
Delete the branch
  • Branch deleted
Branch deleted
Branch deleted

Merged to main

  • Now you have your power platform app solution merged in to your main branch in GitHub, and all of GitHub's log, analysis, and release tooling is available to the solution.
Power Platform Solution merged to main in GitHub
Power Platform Solution merged to main in GitHub

Remember, this is my particular strategy, and you may need to adapt it to fit your specific organisations requirements.  Continue to part 4 which deals with building for deployment into production in Microsoft Power Platform via GitHub.


References

See also: