Azure / Azure/static-web-apps

Github Actions - did not deploy what's in specified output_location and used what's in app_location

Open
#1,380 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

I have a simple HTML frontend app and no API. I'm using parcel (parceljs.org) for building the app.
There is a **src** directory where I have an _index.html_ as well as a few JavaScript and CSS files.
There is a **dist** directory where the built files of the app go.

**To Reproduce**

Here's the sample I took from the [Build configuration](https://learn.microsoft.com/en-us/azure/static-web-apps/build-configuration?tabs=github-actions#build-and-deploy) page from the MS docs with slight changes.

```
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ env.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
###### Repository/Build Configurations ######
app_location: "src" # App source code path relative to repository root
output_location: "../dist" # Built app content directory, relative to app_location - optional
###### End of Repository/Build Configurations ######
skip_api_build: true
app_build_command: npm run build
```
I switched out the token with an environment variable, which I know works because the deployments I tried worked.
Changed the **app_location** to **src**, added **output_location** **../dist** (and also tried **dist**) with no change in behavior.
Added **app_build_command: npm run build**

Here's the excerpt of the logs in the job:
```
/usr/bin/docker run --name dec165c73ca24494564f4d83238bdd7607f76c_4f3a48 --label dec165 --workdir /github/workspace --rm -e "AZURE_STATIC_WEB_APPS_API_TOKEN" -e "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN" -e "INPUT_REPO_TOKEN" -e "INPUT_ACTION" -e "INPUT_APP_LOCATION" -e "INPUT_OUTPUT_LOCATION" -e "INPUT_SKIP_API_BUILD" -e "INPUT_APP_BUILD_COMMAND" -e "INPUT_API_BUILD_COMMAND" -e "INPUT_API_LOCATION" -e "INPUT_APP_ARTIFACT_LOCATION" -e "INPUT_ROUTES_LOCATION" -e "INPUT_SKIP_APP_BUILD" -e "INPUT_CONFIG_FILE_LOCATION" -e "INPUT_PRODUCTION_BRANCH" -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 "ACTIONS_RESULTS_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/[redacted-repo-name]":"/github/workspace" dec165:c73ca24494564f4d83238bdd7607f76c
DeploymentId: 6d6440d0-8d20-4d8e-befb-63a4806b22d1

Try to validate location at: '/github/workspace/src'.
App Directory Location: 'src' was found.
Try to validate location at: '/github/workspace/swa-db-connections'.
Looking for event info
Starting to build app with Oryx
Azure Static Web Apps utilizes Oryx to build both static applications and Azure Functions. You can find more details on Oryx here: https://github.com/microsoft/Oryx
Oryx will build app with the following custom override command: npm run build
---Oryx build logs---

Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues

Oryx Version: 0.2.20231128.3, Commit: 0b76566110f0db32097b869761e056fd9b01848d, ReleaseTagName: 20231128.3

Build Operation ID: b9948febdc3b255e
OS Type : bullseye
Image Type : jamstack

Detecting platforms...
Could not detect any platform in the source directory.
Error: Could not detect the language from repo.

---End of Oryx build logs---
Oryx was unable to determine the build steps. Continuing assuming the assets in this folder are already built. If this is an unexpected behavior please contact support.
Finished building app with Oryx
No Api directory specified. Azure Functions will not be created.
Either no Api directory was specified, or the specified directory was not found. Azure Functions will not be created.
Zipping App Artifacts
Done Zipping App Artifacts
Uploading build artifacts.
Finished Upload. Polling on deployment.
Status: InProgress. Time: 0.0556548(s)
Status: InProgress. Time: 15.1081147(s)
Status: Succeeded. Time: 30.647(s)
Deployment Complete :)
Visit your site at: https://[redacted].azurestaticapps.net
Thanks for using Azure Static Web Apps!
Exiting
```

**Expected behavior**
I am expecting the action to build using **npm run build**, but I don't seem to see the output messages similar to what I see locally, which basically list the files generated in the **dist** directory.
I am expecting after that, the files in the **dist** directory to be deployed to SWA. Instead, the files in the **src** directory was deployed.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.