Hi @Nathaniel Walker,
Even a simple "Hello World" function can fail to deploy if the folder structure doesn't meet the requirements expected by SWA.
- Make sure you have the below folder structure.
api - hello folder (with function.json and index.js)
src - with index.html
- The issue seems to be with your
app_location
andapi_location
. - If you have dist folder , then set the
output_location
as dist. As I am not using any dist folder, I have set it as.
app_location: "src"
api_location: "api"
output_location: "."
My function.json
:
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [ "get" ]
},
{
"type": "http",
"direction": "out",
"name": "res"
}
]
}
My Workflow
file:
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
jobs:
build_and_deploy_job:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_WONDERFUL_FOREST_003096B1E }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
action: "upload"
app_location: "src"
api_location: "api"
output_location: "."
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_WONDERFUL_FOREST_003096B1E }}
action: "close"
Deployment:
Output:
Hope this helps
If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions, please reply back