pnp / docker-spfx

Docker images for working with SharePoint Framework
https://hub.docker.com/r/m365pnp/spfx
MIT License
116 stars 48 forks source link

Automatic Issue Creation when a new SPFx Version Is Out #96

Open shurick81 opened 1 year ago

shurick81 commented 1 year ago

Would it be possible to automate the process to that every time when the new SPFx version is out, we have a new issue created in this project, for updating the docker image?

waldekmastykarz commented 1 year ago

Do you know of a way to implement the trigger without having to stand up resources on Azure?

shurick81 commented 1 year ago

I'm not sure :). Do you know what signal we could use for the trigger? Is there any feed in the internet we could use for even receiving a firm signal that the new SPFx is released? Publicly available release pipelines maybe?

waldekmastykarz commented 1 year ago

SPFx is built internally. The only reliable public signal is the npm feed, which would require polling, which I don't think is a reliable way to go about it. Plus, how would we handle changes to Node version which require us to modify the Dockerfile before building the image? While I'm all for automation, I wonder if in this case it's not overcomplicating it.

shurick81 commented 1 year ago

I have prepared some POC that notifies me when the pipeline fails:

https://github.com/shurick81/docker-spfx/blob/master/.github/workflows/new-spfx-issue.yaml

https://github.com/shurick81/docker-spfx/actions

it would be great if we could also create an issue in Github automatically, not just notify about the failure.

shurick81 commented 1 year ago

This is the only code I added:

name: New SPFx Task

on: 
  schedule:
    # * is a special character in YAML so you have to quote this string
    - cron:  '30 5,17 * * *'

jobs:
  version-compare:
    runs-on: ubuntu-20.04
    container: node:16.20.0
    steps:
    - name: Comparing Current Version
      run: |
        apt-get update
        apt-get install jq -y
        package_info="$(npm view @microsoft/generator-sharepoint --json)"
        latest_version="$(echo "$package_info" | jq '.version' --raw-output)"
        if [ "$latest_version" != "1.17.2" ]; then
          echo "@microsoft/generator-sharepoint latest version is $latest_version";
          exit 1;
        fi;
waldekmastykarz commented 1 year ago

Rather than using a fixed version number in the action and having to update it each time a new version of SPFx has been released, what if we grabbed the latest version of the Docker image that we published and compared against it? Basically, if the latest version on npm and Docker are different, there's work to be done.

shurick81 commented 1 year ago

Yes, good idea for improvement :)