azure static web app + github = cant merge any PR,get“deployment_token was not provided”,but does deploy when doing a normal commit to main

bfrts1fy  于 2023-08-07  发布在  Git
关注(0)|答案(1)|浏览(90)

我们有一个纯html/js静态web应用程序,当我们提交到main时,它通过将html/js部署到静态web应用程序来“构建”它,一切都很好。
我们可以很高兴地提交到main,静态Web应用程序通过.github/workflows/azurexxx.yaml文件神奇地部署。
但是,如果我们想合并PR,它会在构建步骤中失败:
Azure静态Web应用CI/CD /生成和部署作业(pull_request)在48秒后失败
错误是:

Run Azure/static-web-apps-deploy@v1
/usr/bin/docker run --name c9a4a5a9e299732ab04
LOTS OF STUFF
DeploymentId: 5babc754-54b0-4694-9e7d-xxxxx

deployment_token was not provided.
The deployment_token is required for deploying content. If you'd like to continue the run without deployment, add the configuration skip_deploy_on_missing_secrets set to true in your workflow file
An unknown exception has occurred

字符串
我不知道的是为什么它试图做一个部署作为公关的一部分,因为我们只有一个“生产”静态Web应用程序,没有“测试”静态Web应用程序存在,我们可以建立。我们如何告诉github不要尝试构建/部署,而只是合并它,这将自动启动我们知道有效的构建/部署。
yaml文件是:

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
      - 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_PLANT_00xxxx }}
          repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
          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: "/" # Built app content directory - optional
          ###### End of Repository/Build Configurations ######

  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_PLANT_00xxxx }}
          action: "close"


错误消息建议“skip_deploy_on_missing_secrets set to true in your workflow file”。我们如何/在哪里做到这一点?可能这必须在yaml文件中的某个地方,但这是PR的一部分(或者它使用非PR)?

fcipmucu

fcipmucu1#

对于skip_deploy_on_missing_secrets: true的pull请求,部署阶段将被忽略,并且仅在主分支有push或pull请求关闭(即合并)时才会运行。作为此设置的结果,您的拉取请求将不再启动部署阶段,并且一旦将拉取请求合并到主分支中,自动构建/部署过程将照常进行。

我的github工作流脚本:-

  • 我在output_location下面添加了skip_deploy_on_missing_secrets: true *

在这里找到我完整的github工作流程。

name: Azure Static Web Apps CI/CD

on:
  push:
    branches:
      - master
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - master

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
      - 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_GENTLE_FOREST_087983710 }}
          repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
          action: "upload"
          app_location: "/site" # App source code path
          api_location: "" # Api source code path - optional
          output_location: "" # Built app content directory - optional
          skip_deploy_on_missing_secrets: true
          

  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_GENTLE_FOREST_087983710 }}
          action: "close"

字符串
此外,发生此错误是因为PR之后github action工作流无法读取您的秘密,在这里,您需要从Manage deployment token选项卡手动下载Deployment token并将其复制为工作流中的秘密.
x1c 0d1x的数据

相关问题