Skip to content

Test

Test #1

# This workflow checks for the latest Microsoft.PowerApps.CLI version and creates a PR if a newer version is available
name: Update PowerApps CLI Version
on:
push:
branches:
- users/priyanshuag/pac
schedule:
- cron: '0 3 * * *' # Runs daily at 03:00 UTC
workflow_dispatch:
jobs:
check-and-update-cli-version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Get latest Microsoft.PowerApps.CLI version from NuGet
id: get_latest_version
run: |
latest_version=$(curl -s "https://api.nuget.org/v3-flatcontainer/microsoft.powerapps.cli/index.json" | jq -r '.versions[-1]')
echo "latest_version=$latest_version" >> $GITHUB_OUTPUT
- name: Get current CLI version from gulpfile.mjs
id: get_current_version
run: |
current_version=$(grep -oP "const cliVersion = '\K[0-9.]+(?=')" gulpfile.mjs)
echo "current_version=$current_version" >> $GITHUB_OUTPUT
- name: Compare versions
id: compare_versions
run: |
if [ "${{ steps.get_latest_version.outputs.latest_version }}" != "${{ steps.get_current_version.outputs.current_version }}" ]; then
echo "update_needed=true" >> $GITHUB_OUTPUT
else
echo "update_needed=false" >> $GITHUB_OUTPUT
fi
- name: Update gulpfile.mjs with new CLI version
if: steps.compare_versions.outputs.update_needed == 'true'
run: |
sed -i "s/const cliVersion = '[0-9.]*'/const cliVersion = '${{ steps.get_latest_version.outputs.latest_version }}'/" gulpfile.mjs
- name: Create Pull Request to update CLI version
if: steps.compare_versions.outputs.update_needed == 'true'
uses: peter-evans/create-pull-request@v6
with:
commit-message: "chore: update PowerApps CLI version to ${{ steps.get_latest_version.outputs.latest_version }}"
title: "chore: update PowerApps CLI version to ${{ steps.get_latest_version.outputs.latest_version }}"
body: |
This PR updates the PowerApps CLI version in `gulpfile.mjs` from ${{ steps.get_current_version.outputs.current_version }} to ${{ steps.get_latest_version.outputs.latest_version }}.
_Automated PR generated by GitHub Actions._
branch: update/cli-version-${{ steps.get_latest_version.outputs.latest_version }}
delete-branch: true
add-paths: |
gulpfile.mjs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}