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
325 stars 56 forks source link

💢`Azure/static-web-apps-deploy@v1` behavior changed today! Leading to deploy failed. #1282

Closed gyhyfj closed 12 months ago

gyhyfj commented 1 year ago

Describe the bug

I have a nuxt3 project which is deployed on azure swa by github action. In the past few months, this workflow worked well. But! today, it doesn't work. Finally I figured out that I have to change my output_location field in my yml workflow file as this:

 - name: Deploy
   id: deploy
   uses: Azure/static-web-apps-deploy@v1
   with:
     production_branch: 'main'
     azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_LEMON_HILL_017D62D10 }}
     repo_token: ${{ secrets.GITHUB_TOKEN }}
     action: 'upload'
     skip_app_build: true
     skip_api_build: true
     app_location: 'apps/dalle-nuxt3/.output/public'
     api_location: 'apps/dalle-nuxt3/.output/server'
-     output_location: 'apps/dalle-nuxt3/.output/public'
+     output_location: '/'

But it did work well before, and is there any change by github or azure-swa?

gyhyfj commented 1 year ago

The error output in github action was:

Run Azure/static-web-apps-deploy@v1
  with:
    production_branch: main
    azure_static_web_apps_api_token: ***
    repo_token: ***
    action: upload
    skip_app_build: true
    skip_api_build: true
    app_location: apps/dalle-nuxt3/.output/public
    api_location: apps/dalle-nuxt3/.output/server
    output_location: apps/dalle-nuxt3/.output/public
/usr/bin/docker run --name b531[2](https://github.com/developer-zmo/frontend-monorepo/actions/runs/6230611477/job/16910899558#step:7:2)6acf40c141ba8067f67[3](https://github.com/developer-zmo/frontend-monorepo/actions/runs/6230611477/job/16910899558#step:7:3)905ac9[4](https://github.com/developer-zmo/frontend-monorepo/actions/runs/6230611477/job/16910899558#step:7:4)e_9[5](https://github.com/developer-zmo/frontend-monorepo/actions/runs/6230611477/job/16910899558#step:7:5)e88a --label 94351b --workdir /github/workspace --rm -e "INPUT_PRODUCTION_BRANCH" -e "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN" -e "INPUT_REPO_TOKEN" -e "INPUT_ACTION" -e "INPUT_SKIP_APP_BUILD" -e "INPUT_SKIP_API_BUILD" -e "INPUT_APP_LOCATION" -e "INPUT_API_LOCATION" -e "INPUT_OUTPUT_LOCATION" -e "INPUT_API_BUILD_COMMAND" -e "INPUT_APP_ARTIFACT_LOCATION" -e "INPUT_APP_BUILD_COMMAND" -e "INPUT_ROUTES_LOCATION" -e "INPUT_CONFIG_FILE_LOCATION" -e "INPUT_DEPLOYMENT_ENVIRONMENT" -e "INPUT_IS_STATIC_EXPORT" -e "INPUT_DATA_API_LOCATION" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/frontend-monorepo/frontend-monorepo":"/github/workspace" 94351b:5312[6](https://github.com/developer-zmo/frontend-monorepo/actions/runs/6230611477/job/16910899558#step:7:6)acf40c141ba806[7](https://github.com/developer-zmo/frontend-monorepo/actions/runs/6230611477/job/16910899558#step:7:7)f673905ac94e
DeploymentId: b6e3[8](https://github.com/developer-zmo/frontend-monorepo/actions/runs/6230611477/job/16910899558#step:7:8)c1e-d55d-4231-[9](https://github.com/developer-zmo/frontend-monorepo/actions/runs/6230611477/job/16910899558#step:7:9)f9a-3731c7b335ba

Try to validate location at: '/github/workspace/apps/dalle-nuxt3/.output/public'.
App Directory Location: 'apps/dalle-nuxt3/.output/public' was found.
Try to validate location at: '/github/workspace/swa-db-connections'.
Looking for event info
Skipping step to build /github/workspace/apps/dalle-nuxt3/.output/public with Oryx
Try to validate location at: '/github/workspace/apps/dalle-nuxt3/.output/public/apps/dalle-nuxt3/.output/public'.
App artifact folder location `apps/dalle-nuxt3/.output/public` is invalid. Could not detect this directory. Please verify your configuration reflects your repository structure.

For further information, please visit the Azure Static Web Apps documentation at https://docs.microsoft.com/en-us/azure/static-web-apps/
If you believe this behavior is unexpected, please raise a GitHub issue at https://github.com/azure/static-web-apps/issues/
Exiting
PolarFox commented 1 year ago

Got the same results with Azure Devops pipeline.

Try to validate location at: '/working_dir/app'.
App Directory Location: 'app/' was found.
Try to validate location at: '/working_dir/swa-db-connections'.
Looking for event info
Skipping step to build /working_dir/app with Oryx
Try to validate location at: '/working_dir/app/dist'.
App artifact folder location 'dist' is invalid. Could not detect this directory. Please verify your configuration reflects your repository structure.

For further information, please visit the Azure Static Web Apps documentation at https://docs.microsoft.com/en-us/azure/static-web-apps/
If you believe this behavior is unexpected, please raise a GitHub issue at https://github.com/azure/static-web-apps/issues/
Exiting

With task:


- task: AzureStaticWebApp@0
  inputs:
    app_location: 'app/'
    api_build_command: 'npm install && npm run build'
    output_location: 'dist'
    skip_app_build: true
    production_branch: 'main'
    azure_static_web_apps_api_token: $(dev-deployment-token)
serhatkepez commented 1 year ago

Having the same results / issues from Azure DevOps Pipeline


2023-09-19T08:22:56.6212330Z App Directory Location: '14342' was found.
2023-09-19T08:22:56.6212639Z Try to validate location at: '/working_dir/swa-db-connections'.
2023-09-19T08:22:56.6217828Z Looking for event info
2023-09-19T08:22:56.6225187Z Could not get event info. Proceeding
2023-09-19T08:22:57.5597699Z Skipping step to build /working_dir/14342 with Oryx
2023-09-19T08:22:57.5625383Z Try to validate location at: '/working_dir/14342/home/vsts/work/r1/a/14342'.
2023-09-19T08:22:57.5625732Z ##[error]App artifact folder location `/home/vsts/work/r1/a/14342` is invalid. Could not detect this directory. Please verify your configuration reflects your repository structure.
2023-09-19T08:22:57.6900870Z 
2023-09-19T08:22:57.6901790Z ##[warning]For further information, please visit the Azure Static Web Apps documentation at https://docs.microsoft.com/en-us/azure/static-web-apps/
2023-09-19T08:22:57.6902279Z ##[warning]If you believe this behavior is unexpected, please raise a GitHub issue at https://github.com/azure/static-web-apps/issues/
2023-09-19T08:22:57.6902516Z ##[warning]Exiting
2023-09-19T08:22:57.8253259Z ##[error]Error: The process '/usr/bin/bash' failed with exit code 1
MATTHEWTAYLOR1995 commented 1 year ago

We're also having the same issue;

App artifact folder location /dist/apps/host is invalid. Could not detect this directory. Please verify your configuration reflects your repository structure.

I also raised this here - https://developercommunity.visualstudio.com/t/AzureStaticWebApp0-task-failing-on-depl/10469614

I think the issue is potentially the deployment container they use mcr.microsoft.com/appsvc/staticappsclient:stable in this task has been updated as the sha256 has changed to sha256:6fbd668f58fa6fca3a18c10122fe4fefd36719a4fb2928fc4027a9bb508ce3b8 since the failures began.

e-knaake-covadis commented 1 year ago

This issue also exists for an Angular application that has been build previously (by a build/git pipeline) and is only downloaded from an artifact in the release pipeline. Making the output location empty fixes it for now (for me)

To clarify with build pipeline I mean this tab from Azure DevOps: image

and with release pipeline: image

YanivKnoll commented 1 year ago

@e-knaake-covadis , you changed the "outputPath": "dist/", in angular json tp empty?

e-knaake-covadis commented 1 year ago

@e-knaake-covadis , you changed the "outputPath": "dist/", in angular json tp empty?

No I changed the release pipeline

richardseftonTNP commented 1 year ago

We are experiencing the same issues in all out Azure DevOps release pipelines.

2023-09-19T13:52:32.7119924Z Try to validate location at: '/working_dir/./public/./public'.
2023-09-19T13:52:32.7120164Z ##[error]App artifact folder location `./public` is invalid. Could not detect this directory. Please verify your configuration reflects your repository structure.
2023-09-19T13:52:32.8318086Z 
2023-09-19T13:52:32.8319195Z ##[warning]For further information, please visit the Azure Static Web Apps documentation at https://docs.microsoft.com/en-us/azure/static-web-apps/
2023-09-19T13:52:32.8319640Z ##[warning]If you believe this behavior is unexpected, please raise a GitHub issue at https://github.com/azure/static-web-apps/issues/
2023-09-19T13:52:32.8320078Z ##[warning]Exiting
2023-09-19T13:52:32.9852424Z ##[error]Error: The process '/usr/bin/bash' failed with exit code 1
e-knaake-covadis commented 1 year ago

Maybe related: Since this issue arose and we set the output location the default mime types did not work any more for our application. .js files where being served as text/html instead of text/javascript as they used to. This is fixed for now by updating the staticwebapp.config.json mimeTypes section

richardseftonTNP commented 1 year ago

Maybe related: Since this issue arose and we set the output location the default mime types did not work any more for our application. .js files where being served as text/html instead of text/javascript as they used to. This is fixed for now by updating the staticwebapp.config.json mimeTypes section

I don't think this is related to mime types when serving files. This seems to be pipeline deployments breaking.

thomasgauvin commented 1 year ago

Hi folks, I'm looking into these reports and trying to reproduce the issue, I can't immediately reproduce it, so there may be something specifically related to your resources. Please create support issues for this issue so we can properly gather the information we need and have a reliable channel to communicate.

thomasgauvin commented 1 year ago

Hi all, we've looked into this and are rolling back changes. Can you provide successful builds with the details of the configuration in the workflow file? If you cannot share here, please open a support ticket

We're still investigating this to determine the issue

marco-manrique commented 1 year ago

Thanks! the release pipelines work again

thomasgauvin commented 1 year ago

I've verified that builds with the StaticSitesClient that have skip_app_build enabled treat the output_location as absolute paths, as had previously been the case.

The new changes (which have since been rolled back) began treating the output_location as relative paths when skip_app_build was enabled. This was rolled back and we'll be rectifying this behavior.

The problem should now be mitigated and your builds should work correctly

serhatkepez commented 1 year ago

Our release pipelines are working again!

cjk7989 commented 11 months ago

Hi @PolarFox and @serhatkepez, I'm investigating the issue though it worked after rolling back. I would appreciate it if you could share the type of your swa framework (like angular, react) and how you deployed them (like using github action, ot swa-cli, etc). Feel free to reply, thanks : )