Static-web-apps: Accessing github registrys with yarn

Created on 16 Jul 2020  路  5Comments  路  Source: Azure/static-web-apps

馃憢

I've been wrestling for a day or two with trying to build a static webapp using yarn that needs to fetch a package published by another one of my organisation's repos.

I've tried quite a few of the techniques recommended in the related issues (https://github.com/Azure/static-web-apps/issues/44) but the crux seems to be that when the build and deploy stage is executed I can't find a way to avoid getting a 401 response when it fetches the package as part of the yarn install command called when a yarn lockfile is present. I can successfully build the project in a previous step:

      - uses: actions/setup-node@v1
        with:
          node-version: '13.x'
          registry-url: 'https://npm.pkg.github.com'
          scope: '@xxxxxxxxx'
          always-auth: true
      - run: yarn && yarn run build && yarn run export
        env:
          NODE_AUTH_TOKEN: ${{ secrets.PACKAGES_TOKEN }}

but I'm unable to stop yarn install getting called in the subsequent stage. Potential options as I see it are:

  1. Split the build and deploy jobs up so the build step can be ignored
  2. Improve support for accessing github registrys (44 covers similar stuff)
  3. Modify the behaviour of app_build_command to not call yarn install automatically and delegate that responsibility to the person providing the custom build command. This seems like the easiest fix to me but I'll admit I'm very new to all this.

Thanks!

Most helpful comment

@kichalla do you have any advice on 2?

@henryjcee you can actually avoid the build altogether if you'd like to. If you do the build via the normal Github Action workflow and then set the app_location to be the directory where you expect the content to be, we will treat it like a purely static website and skip the build.

All 5 comments

@kichalla do you have any advice on 2?

@henryjcee you can actually avoid the build altogether if you'd like to. If you do the build via the normal Github Action workflow and then set the app_location to be the directory where you expect the content to be, we will treat it like a purely static website and skip the build.

That's very useful to know, I'll give it a go. That should be good enough for my use case plus I imagine quite a few others! Thanks.

edit: I guess this is good to close?

Let me know if this doesn't fix your issue; we are continually working to improve our detection and build steps, so we are hoping to avoid this sort of manual setup later on. Thanks for trying out our preview!

Worked well for me and all I'd suggest is to make it more prominent in the docs. Thanks for your help.

cc @craigshoemaker

Was this page helpful?
0 / 5 - 0 ratings