|
| 1 | +# This workflow checks for the latest Microsoft.PowerApps.CLI version and creates a PR if a newer version is available |
| 2 | +name: Update PowerApps CLI Version |
| 3 | + |
| 4 | +on: |
| 5 | + schedule: |
| 6 | + - cron: '0 3 * * *' # Runs daily at 03:00 UTC |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + check-and-update-cli-version: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Checkout repository |
| 14 | + uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - name: Set up Node.js |
| 17 | + uses: actions/setup-node@v4 |
| 18 | + with: |
| 19 | + node-version: 20 |
| 20 | + |
| 21 | + - name: Get latest Microsoft.PowerApps.CLI version from NuGet |
| 22 | + id: get_latest_version |
| 23 | + run: | |
| 24 | + latest_version=$(curl -s "https://api.nuget.org/v3-flatcontainer/microsoft.powerapps.cli/index.json" | jq -r '.versions[-1]') |
| 25 | + echo "latest_version=$latest_version" >> $GITHUB_OUTPUT |
| 26 | +
|
| 27 | + - name: Get current CLI version from gulpfile.mjs |
| 28 | + id: get_current_version |
| 29 | + run: | |
| 30 | + current_version=$(grep -oP "const cliVersion = '\K[0-9.]+(?=')" gulpfile.mjs) |
| 31 | + echo "current_version=$current_version" >> $GITHUB_OUTPUT |
| 32 | +
|
| 33 | + - name: Compare versions and update if needed |
| 34 | + id: compare_versions |
| 35 | + run: | |
| 36 | + if [ "${{ steps.get_latest_version.outputs.latest_version }}" != "${{ steps.get_current_version.outputs.current_version }}" ]; then |
| 37 | + echo "update_needed=true" >> $GITHUB_OUTPUT |
| 38 | + else |
| 39 | + echo "update_needed=false" >> $GITHUB_OUTPUT |
| 40 | + fi |
| 41 | +
|
| 42 | + - name: Create Pull Request to update CLI version |
| 43 | + if: steps.compare_versions.outputs.update_needed == 'true' |
| 44 | + uses: peter-evans/create-pull-request@v6 |
| 45 | + with: |
| 46 | + commit-message: "chore: update PowerApps CLI version to ${{ steps.get_latest_version.outputs.latest_version }}" |
| 47 | + title: "chore: update PowerApps CLI version to ${{ steps.get_latest_version.outputs.latest_version }}" |
| 48 | + body: | |
| 49 | + 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 }}. |
| 50 | +
|
| 51 | + _Automated PR generated by GitHub Actions._ |
| 52 | + branch: update/cli-version-${{ steps.get_latest_version.outputs.latest_version }} |
| 53 | + delete-branch: true |
| 54 | + add-paths: | |
| 55 | + gulpfile.mjs |
| 56 | + env: |
| 57 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 58 | + |
| 59 | + - name: Update gulpfile.mjs with new CLI version |
| 60 | + if: steps.compare_versions.outputs.update_needed == 'true' |
| 61 | + run: | |
| 62 | + sed -i "s/const cliVersion = '[0-9.]*'/const cliVersion = '${{ steps.get_latest_version.outputs.latest_version }}'/" gulpfile.mjs |
0 commit comments