6

I have a simple, static website that I'm attempting to deploy as an Azure Static Web App (no framework) using GitHub Actions. My directory structure is:

├── .github/workflows/
├── css/
├── img/
├── js/
├ index.html

When I make a push to the GitHub repo, the Azure Static Web Apps CI/CD action starts the build & deploy job. In my YAML configuration file in the .github/workflows directory, I have set the following for my Repository/Build Configuration:

app_location: "/"    # The app source code is in the root directory for the repo
api_location: ""     # There is no API that needs to be configured
output_location: "/" # my index.html file is in the root directory for the repo

However, I get the following error in my Build and Deploy Job:

Failed to find a default file in the app artifacts folder (/). Valid default files: index.html,Index.html. If your application contains purely static content, please verify that the variable 'app_location' in your workflow file (located in .github/workflows) points to the root of your application.

Why am I getting this error when I've specified where the index.html file is?

Jesuisme
  • 1,805
  • 1
  • 31
  • 41

2 Answers2

11

Because the deploy container was based on Ubuntu, I guessed that the output location may be getting confused with the root directory for the entire system.

So, I set the output location in the workflow YAML file to:

output_location: "./"

With that change, the build completes and the static web app deploys successfully.

Jesuisme
  • 1,805
  • 1
  • 31
  • 41
  • 1
    this did it for me, i added an issue with the MS documentation to change their example. https://github.com/MicrosoftDocs/azure-docs/issues/76222 – Brandon.Staley Jun 01 '21 at 16:40
  • Thank you, however I still have a problem, If refresh the app on any other page other then index, the web doesn't load it. Do you have idea why? – Hamza Abbas Mar 16 '22 at 22:14
  • @HamzaAbbas Sorry, I don't know. If you are updating, committing, and pushing some file other than index.html and it doesn't trigger an app update, I would check your .dockerignore and make sure you aren't leaving the files or directory out of the container. Not sure what else to check after that. – Jesuisme Mar 17 '22 at 03:50
  • I meant the rotues, If routes is anything else then the base url and I refresh the page, it doesn't load it. – Hamza Abbas Mar 17 '22 at 11:05
  • 1
    @HamzaAbbas For static web apps, everything is configured relative to the base url or the application root directory. Here's a link to the documentation: https://aka.ms/swaworkflowconfig – Jesuisme Mar 17 '22 at 15:30
2

I have the same problem, I tried to run this command locally:

`npm run build`

then I checked the root folder of the app to find what is the name of the build folder and it fixed my problem.

Mehdi Sheikh
  • 201
  • 3
  • 9
  • 1
    Thanks mate. I guess this should be marked as a valid answer too. If you are unable to figure out what is your 'output_location', run `npm run build` locally and do a quick search to find where the index.html file is located at. In my case it was output_location: ".next/server/pages" – Poornamith Jun 12 '22 at 13:03