gh-pages 部署问题,作业在部署时失败您尝试部署的目录...不存在

问题描述

gh-pages 部署失败,出现下一个错误My repository failed job

Checking configuration and starting deployment… ?
Error: The directory you're trying to deploy named /home/runner/work/azure-flask-react/azure-flask-react/dist doesn't exist. Please double check the path and any prerequisite build scripts and try again. ❗
Deployment Failed! ❌

duplicated directory path in gh-pages job

我正在尝试在 Github 上部署 ReactApp,除了部署在 Azure 上托管的 Python-Flask 后端,而且后端应用程序有它自动生成的作业 yml

但是对于前端应用程序,我遵循了 this answer 并在 yml 中手动添加了第二个作业,因为我需要提供 env.variables。

我的后端部署成功,但前端应用由于路径重复而不断失败 /home/runner/work/azure-flask-react/azure-flask-react/dist

Here is my ymlpackage.json 但没有额外提及该目录...

# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Python app to Azure Web App - first-py-app

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  front-build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v1

      - name: Build
        run: |
          npm --prefix front-app install
          npm --prefix front-app run-script build
        env:
          REACT_DEV_SERVER_URL: ${{ secrets.REACT_DEV_SERVER_URL }},REACT_DEV_FRONT_APP_URL: ${{ secrets.REACT_DEV_FRONT_APP_URL }}

      - name: Deploy
        uses: JamesIves/github-pages-deploy-action@releases/v3
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN_KEY }}
          BRANCH: gh-pages
          FOLDER: dist

  back-build-and-deploy:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@master

      - name: Set up Python version
        uses: actions/setup-python@v1
        with:
          python-version: '3.8'

      - name: Build using AppService-Build
        uses: azure/appservice-build@v2
        with:
          platform: python
          platform-version: '3.8'

      - name: 'Deploy to Azure Web App'
        uses: azure/webapps-deploy@v2
        with:
          app-name: 'first-py-app'
          slot-name: 'production'
          publish-profile: ${{ secrets.AzureAppService_PublishProfile_7edcdecca83a4354a87943f94bb32fca }}

{
  ...
  "homepage": "https://nikonov91-dev.github.io/azure-flask-react","scripts": {
    ...
    "predeploy": "npm run build","deploy": "gh-pages -d build"
  },}

和我的文件结构

azure-proj
  |-front-app (containing reactjs)
     |-package.json
     |-node_modules
     |-src
  |-app.py (python-flask application which deploys successfully)

解决方法

我误解了问题消息,问题不是重复问题是在gh-pages YML设置

文件夹中传递的丢失的内部路径

enter image description here

BUILD 步骤有提示

enter image description here

还有一件事:不要忘记获取并添加到 GH 您的 personal-access-token

enter image description here