9

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?

2 Answers 2

12

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.

Sign up to request clarification or add additional context in comments.

5 Comments

this did it for me, i added an issue with the MS documentation to change their example. github.com/MicrosoftDocs/azure-docs/issues/76222
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?
@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.
I meant the rotues, If routes is anything else then the base url and I refresh the page, it doesn't load it.
@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: aka.ms/swaworkflowconfig
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.

2 Comments

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"
Once you know the name of the build folder, what is the next step to fix the problem?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.