Export To Branch #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Export To Branch | |
on: | |
workflow_dispatch: | |
inputs: | |
solution_name: | |
description: "Name of the solutions you would like to export." | |
required: true | |
jobs: | |
export-solution: | |
runs-on: windows-latest | |
steps: | |
- id: date | |
name: Get current datetime | |
run: | | |
$datetime = $(Get-Date -Format "yyyy-MM-ddTHH:mm:ss") | |
echo "datetime=$datetime" >> "$GITHUB_OUTPUT" | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup .NET Core environment | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: '6.0' | |
- name: Install PAC CLI | |
run: | | |
dotnet tool install --global Microsoft.PowerApps.CLI.Tool | |
- name: Auth | |
run: | | |
pac auth create --kind CDS --url ${{ secrets.POWERPLATFORM_URL }} --username ${{ secrets.POWERPLATFORM_USERNAME }} --password ${{ secrets.POWERPLATFORM_PASSWORD }} | |
env: | |
POWERPLATFORM_URL: ${{ secrets.POWERPLATFORM_URL }} | |
POWERPLATFORM_USERNAME: ${{ secrets.POWERPLATFORM_USERNAME }} | |
POWERPLATFORM_PASSWORD: ${{ secrets.POWERPLATFORM_PASSWORD }} | |
- name: Initialize Solution If DNE | |
run: | | |
if (!(Test-Path -Path "./Solutions/${{ github.event.inputs.solution_name }}")) { | |
pac solution init --publisher-name PowerAccelerator --publisher-prefix mpa --outputDirectory "./Solutions/${{ github.event.inputs.solution_name }}" | |
$cdsprojFilePath = "./Solutions/${{ github.event.inputs.solution_name }}/${{ github.event.inputs.solution_name }}.cdsproj" | |
[xml]$xmlDoc = Get-Content $cdsprojFilePath | |
$propertyGroup = $xmlDoc.CreateElement("PropertyGroup") | |
$solutionPackageType = $xmlDoc.CreateElement("SolutionPackageType") | |
$solutionPackageType.InnerText = "Both" | |
$propertyGroup.AppendChild($solutionPackageType) | |
$xmlDoc.Project.AppendChild($propertyGroup) | |
$xmlDoc.Save($cdsprojFilePath) | |
} | |
- name: Sync Solution from Environment | |
run: | | |
cd ./Solutions/${{ github.event.inputs.solution_name }} | |
pac solution sync --processCanvasApps | |
cd ../../ | |
- name: Create and push to new branch | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "github-actions@github.com" | |
git checkout -b "${{ github.event.inputs.solution_name }}-${{ steps.date.outputs.datetime }}" | |
git add . | |
git commit -m "Synced ${{ github.event.inputs.solution_name }} Power Platform Solution" | |
git push --set-upstream origin "${{ github.event.inputs.solution_name }}-${{ steps.date.outputs.datetime }}" |