Skip to content

Update workflow to create GitHub issue for CLI version #6

Update workflow to create GitHub issue for CLI version

Update workflow to create GitHub issue for CLI version #6

# 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
permissions:
contents: write
pull-requests: write
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: Generate issue content file
if: steps.compare_versions.outputs.update_needed == 'true'
run: |
echo "A new version of Microsoft.PowerApps.CLI is available on NuGet." > .github/cli-update-issue-template.md
echo "" >> .github/cli-update-issue-template.md
echo "Current version in gulpfile.mjs: ${{ steps.get_current_version.outputs.current_version }}" >> .github/cli-update-issue-template.md
echo "Latest version on NuGet: ${{ steps.get_latest_version.outputs.latest_version }}" >> .github/cli-update-issue-template.md
echo "" >> .github/cli-update-issue-template.md
echo "Please update the CLI version in the repository." >> .github/cli-update-issue-template.md
echo "" >> .github/cli-update-issue-template.md
echo "For implementation reference, see PR #1236." >> .github/cli-update-issue-template.md
- name: Create GitHub issue to update CLI version and assign to Copilot
if: steps.compare_versions.outputs.update_needed == 'true'
uses: peter-evans/create-issue-from-file@v5
with:
title: "Update PowerApps CLI version to ${{ steps.get_latest_version.outputs.latest_version }}"
content-filepath: .github/cli-update-issue-template.md
labels: "automation,dependencies"
assignees: "github-copilot[bot]"
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}