Using PAC CLI inside GitHub Actions pipeline


GitHub Actions becomes a more and more popular choice used as a continuous integration and continuous delivery platform. We may also use it for building Power Platform solutions. There is a GitHub Actions for the Power Platform project available and still under development. It provides a wrapper for the Power Platform Command Line Interface (PAC CLI). Unfortunately, due to the very fast development of PAC CLI features, not all the commands are currently covered by the related actions. Fortunately, there is a possibility to execute a Power Platform command directly on the GitHub Actions agent. Unfortunately again, when you try to do it, you’ll probably see the following error:
The term 'pac' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
There are lot of different approaches for solving this problem described in the Internet.
For example:
You can download and install PAC CLI in a known path every time your actions workflow starts. This makes sense but increases workflow execution time.
You can hard-code the PAC CLI path in the pipeline body. This works but it adds an additional dependency to our flow logic, which we cannot control. And the paths will likely differ on Windows and Linux-hosted agents.
There is also a possibility of finding your PAC CLI path on the agent machine using command line code. This is possible but adds several lines of complex, not-looking-nice code to your pipeline definition.
Fortunately, starting from the 1.5.0 version, there is a possibility of adding a new parameter to the action-install action, which gives us the possibility of executing Power Platform commands without the necessity of doing all the above-described magic.
Ladies and gentlemen, please welcome “add-tools-to-path” parameter:
- name: Install Power Platform Tools
uses: microsoft/powerplatform-actions/actions-install@v1
with:
add-tools-to-path: true
Your welcome 😊!
Subscribe to my newsletter
Read articles from Piotr Gaszewski directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
