Skip to content

Instantly share code, notes, and snippets.

@bsorrentino
Last active March 24, 2021 23:02
Show Gist options
  • Save bsorrentino/471a1008c55475cf55f670c86717a6c6 to your computer and use it in GitHub Desktop.
Save bsorrentino/471a1008c55475cf55f670c86717a6c6 to your computer and use it in GitHub Desktop.
Github Action - Scaffolds out your new PCF repo
#
# inspired by - https://github.com/rajyraman/pcf-template-dataset
#
name: pcf-init
on:
workflow_dispatch:
push:
branches: [master]
jobs:
build:
runs-on: windows-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v2
- id: checkpcfconfig
run: |
Test-Path pcfconfig.json
echo "::set-output name=exists::$(Test-Path pcfconfig.json)"
- run: echo "::set-env name=GIT_REDIRECT_STDERR::2>&1"
if: steps.checkpcfconfig.outputs.exists != 'True'
- name: Use Node.js ${{ matrix.node-version }}
if: steps.checkpcfconfig.outputs.exists != 'True'
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install PCF CLI
if: steps.checkpcfconfig.outputs.exists != 'True'
run: |
nuget install Microsoft.PowerApps.CLI
$pcfPath = "$(Resolve-Path ".\Microsoft.PowerApps.CLI*\tools" | Select -ExpandProperty Path)\pac"
$pcfName = $('${{ github.repository }}' -replace '${{ github.repository_owner }}/', '' -replace '[^a-zA-Z]', '')
Remove-Item .gitignore -ErrorAction Ignore
& $pcfPath pcf init -ns ${{ github.repository_owner }}.PCF.Components -n $pcfName -t dataset
npm install
mkdir Solution/$pcfName
cd Solution/$pcfName
& $pcfPath solution init -pn ${{ github.repository_owner }} -pp '${{ github.repository_owner }}'.Substring(0,3)
& $pcfPath solution add-reference -p ${{ github.workspace }}
cd ${{ github.workspace }}
Add-Content -Path .gitignore -Value "`r`n/Microsoft.PowerApps.CLI*`r`n/System.ComponentModel.Composition*" -NoNewLine
# Set-Content -Path 'README.md' -Value "# $pcfName`r`n`r`nDetails about this component" -NoNewLine
#
# Remove workflow after run, useful if you setup a project template
#
# Remove-Item .github/workflows/pcfinit.yml -Force
- name: Commit PCF components to repo
if: steps.checkpcfconfig.outputs.exists != 'True'
run: |
Write-Host "****...Push code to repo...****"
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add --all
git tag pcf-tempate -f
git commit -m "Add PCF Template"
git -c http.extraheader="AUTHORIZATION: Bearer ${{ secrets.GITHUB_TOKEN }}" push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment