Tenho um aplicativo Angular que desejo implantar com Aplicativos Web Estáticos do Azure. Segui o guia Início Rápido: Crie seu primeiro aplicativo Web estático , que configura um Aplicativo Web Estático por meio do Portal do Azure.
Em seguida, obtenho um fluxo de trabalho de Ações do Github gerado automaticamente que cria e implanta o aplicativo em aplicativos Web estáticos do Azure. Modifiquei o fluxo de trabalho para usar yarn
em vez de npm
, pois meu projeto usa yarn
.
Aqui está meu arquivo de fluxo de trabalho:
name: Azure Static Web Apps CI/CD
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- master
permissions:
contents: read
id-token: write
issues: write
pull-requests: write
jobs:
build_and_deploy:
if:
github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: ubuntu-latest
name: Build and Deploy
steps:
- uses: actions/checkout@v4
with:
submodules: true
lfs: false
- name: Get Yarn Cache
uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version-file: '.nvmrc'
- name: Install OIDC Client from Core Package
run: yarn add @actions/[email protected] @actions/http-client
- name: Get Id Token
uses: actions/github-script@v6
id: idtoken
with:
script: |
const core = require('@actions/core')
return await core.getIDToken()
result-encoding: string
- 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_xxx }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: 'upload'
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: '/' # App source code path
api_location: '' # Api source code path - optional
output_location: '<my-output-location>' # Built app content directory - optional
github_id_token: ${{ steps.idtoken.outputs.result }}
skip_api_build: true # Set the value to true to skip building the API functions.
###### End of Repository/Build Configurations ######
close_pull_request:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request
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_xxx }}
action: 'close'
A tarefa Fechar solicitação de pull falha com o seguinte erro ao tentar excluir a visualização do ambiente após mesclar uma solicitação de pull:
Motivo: Nenhum site estático correspondente encontrado.
Saída da solicitação de pull de fechamento :
##[group]Run Azure/static-web-apps-deploy@v1
with:
app_location: /
azure_static_web_apps_api_token: ***
action: close
##[endgroup]
##[command]/usr/bin/docker run --name <docker-container-id> --label <docker-label> --workdir /github/workspace --rm -e "INPUT_APP_LOCATION" -e "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN" -e "INPUT_ACTION" -e "INPUT_API_BUILD_COMMAND" -e "INPUT_API_LOCATION" -e "INPUT_APP_ARTIFACT_LOCATION" -e "INPUT_OUTPUT_LOCATION" -e "INPUT_APP_BUILD_COMMAND" -e "INPUT_REPO_TOKEN" -e "INPUT_ROUTES_LOCATION" -e "INPUT_SKIP_APP_BUILD" -e "INPUT_CONFIG_FILE_LOCATION" -e "INPUT_SKIP_API_BUILD" -e "INPUT_PRODUCTION_BRANCH" -e "INPUT_DEPLOYMENT_ENVIRONMENT" -e "INPUT_IS_STATIC_EXPORT" -e "INPUT_DATA_API_LOCATION" -e "INPUT_GITHUB_ID_TOKEN" -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_ID_TOKEN_REQUEST_URL" -e "ACTIONS_ID_TOKEN_REQUEST_TOKEN" -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/<repository>/<repository>":"/github/workspace" <docker-image-id>
DeploymentId: <deployment-id>
Looking for event info
The content server has rejected the request with: BadRequest
Reason: No matching static site found.
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
Tentei regenerar o token da API do Azure Static Web Apps e atualizá-lo no GitHub, mas o problema persiste.
Pergunta: Como posso resolver o erro "Nenhum site estático correspondente encontrado" no job Fechar Pull Request ? Há algo errado com a configuração do meu fluxo de trabalho?
Quando usei seu arquivo de fluxo de trabalho, encontrei o mesmo erro. Para resolvê-lo, removi a linha
github_id_token: ${{ steps.idtoken.outputs.result }}
do arquivo de fluxo de trabalho e funcionou.Testei o fluxo de trabalho abaixo para um projeto Angular de exemplo usando Yarn e o implantei com sucesso nos Aplicativos Web Estáticos do Azure.
fluxo de trabalho:
Ele foi implantado com sucesso no Aplicativo Web Estático do Azure, conforme mostrado abaixo.
Saída do aplicativo Web estático do Azure: