Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
326 stars 56 forks source link

skip_deploy_on_missing_secrets is not supported #679

Open brianharwell opened 2 years ago

brianharwell commented 2 years ago

Describe the bug

A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Set up a build task and do not include the `` parameter
steps:
- task: AzureStaticWebApp@0
  inputs:
    app_location: 'MyApp'
    app_build_command: 'dotnet build'
    output_location: 'wwwroot'
    skip_deploy_on_missing_secrets: true
    # azure_static_web_apps_api_token: $(api_token)

Here is the error

Verbose logging enabled
deployment_token was not provided.
The deployment_token is required for deploying content. If you'd like to continue the run without deployment, add the configuration skip_deploy_on_missing_secrets set to true in your deployment configuration file
An unknown exception has occurred
Failed to record upload telemtry.
miwebst commented 2 years ago

Hey @brianharwell we need to make this logging message more concrete. We are expecting this to be an environment variable not an input. If you specify it as an env var this should work.

kareldeman commented 2 years ago

I have the same problem and although I have added "skip_deploy_on_missing_secrets" as an environment variable (I just added it in the variables configuration), I still get the error "_The deployment_token is required for deploying content. If you'd like to continue the run without deployment, add the configuration skip_deploy_on_missingsecrets set to true in your deployment configuration file". All I want is the single page application we have to only build in the build pipeline and then in the release pipeline to not build it, but deploy it - in the same way we do it with our Azure Function Apps. I get this behavior either when I use a YAML or use the "deploy azure static web app [preview]" task... note: running on ubuntu latest. I am also not sure if I have set the environment variable correctly though - so help on how to make sure it is set would be very appreciated...

brianharwell commented 2 years ago

All I want is the single page application we have to only build in the build pipeline and then in the release pipeline to not build it, but deploy it - in the same way we do it with our Azure Function Apps.

That's exactly what I am trying to do

miwebst commented 2 years ago

@kareldeman can you share your updated workflow file? Assuming DevOps as well based on the above.

kareldeman commented 2 years ago

Here is the YAML for the Static Web App (which is in preview) task I added:

steps:
- task: AzureStaticWebApp@0
  displayName: 'Static Web App: '
  inputs:
    workingDirectory: '$(System.DefaultWorkingDirectory)/_FE_Client'
    app_location: /MVP
    app_build_command: 'npm run build -- web'
    output_location: dist/apps/web
    skip_app_build: false
    verbose: false

Notice I did not provide the $(deployment_token) as I don't want the above to deploy. I added the "skip_deploy_on_missing_secrets" to the Pipeline variables and set it to true:

image

In the Initialize Job I can see the "skip_deploy_on_missing_secrets" in the "environment variables available are below" section:

image

With the above, I still get the following error:

image

HarryHuy commented 1 year ago

I get the same issue today. Had you guys resolved it @kareldeman @brianharwell ?

quetzalcoatl commented 1 year ago

There's not much info on the internet about this parameter. However, at least Dapr docs suggest that it should work, and I doubt they'd put it in their docs if it didn't (here).

Sure enough, I had problems getting it working as well.

One thing to notice there is that Dapr docs actually show a GitHub Action, and they work a little bit differently than Azure CICD YAML Pipelines, which I was using.

@miwebst hinted that this magic undocumented parameter should be passed as an environment variable.
I was passing it as an input. So I tried setting it as ENV and it worked!

  - task: AzureStaticWebApp@0
    inputs:
      app_location: ...blahblahblah
      ....
      #skip_deploy_on_missing_secrets: true
      # ABOVE: this one is documented in few places, but it's expected to be a ENV var!
      #see https://github.com/Azure/static-web-apps/issues/679
    env:
      SKIP_DEPLOY_ON_MISSING_SECRETS: true

Maybe GitHubActions forward these params to envs automatically?

@kareldeman I noticed in your snippet that you don't define env and that you're counting on passinv env values from a different source. Could you try out adding env part like I pasted above?