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.
Contents
- Automate the publication of your Power Platform solution via GitHub
- Pre-requisites
- Create a repository
- Create a new secrets for Service Principal Authentication
- Create a GitHub Action to export and unpack the solution to a new branch in your GitHub repository
- Commit the changes to GitHub
- GitHub Action created
- Test the GitHub Action
- Run the workflow
- Check the branch was created and merge it to your main branch
- Merged to main
References
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.

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.

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

Commit the changes to GitHub
- Now commit the changes and your workflow is 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"

- 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.

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.

- 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.

- Create the 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.

- Delete the branch as it is now no longer required.

- 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.

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:
- Tutorial — Automate solution deployment using GitHub Actions for Microsoft Power Platform — Microsoft
- GitHub — powerplatform-actions-lab/sample-workflows /export-and-branch-solution-with-spn-auth.yml — Microsoft
- GitHub — working example power platform app export and branch, build and release to production via GitHub — Multizone
- Microsoft — Team development and Source control with solution files