You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用GitHub Actions部署Flask应用至Cloud Foundry遇文件缺失错误求助

问题分析与解决方案

错误原因

你遇到的错误Can't find 'action.yml', 'action.yaml' or 'Dockerfile' for action for action 'ibpgithub/testserver123@main',核心原因是:

  • 部署步骤中指定的ibpgithub/testserver123@main不是合法的GitHub Action。GitHub Actions要求作为Action的仓库必须在根目录包含action.yml/action.yaml(定义Action元数据)或Dockerfile(容器化Action),而你的这个仓库缺少这些必需文件,导致Action无法被加载执行。

另外,你的main.yml还有两处配置错误:

  • actions/setup-python步骤中错误添加了fetch-depth、repository、path参数,这些是actions/checkout的参数,不属于setup-python,会导致无效配置。
  • checkout步骤没有指定目标仓库和路径,后续依赖安装可能找不到文件。

修正方案

方案1:直接用Run步骤部署(推荐,无需额外Action仓库)

放弃使用自定义Action,直接在GitHub Actions中安装CF CLI并执行部署命令,修改后的main.yml如下:

name: CF_CLI_Action_testserver123
env:
  PYTHON_VERSION: '3.8'

on:
  push:
    branches: ['main']

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
          repository: my-repo/testserver123
          path: testserver123

      - name: Set up Python version
        uses: actions/setup-python@v3.0.0
        with:
          python-version: ${{ env.PYTHON_VERSION }}
          cache: 'pip'

      - name: Create and start virtual environment
        run: |
          cd testserver123
          python -m venv venv
          source venv/bin/activate

      - name: Install dependencies
        run: |
          cd testserver123
          pip install -r requirements.txt

      - name: Deploy to Cloud Foundry
        run: |
          cd testserver123
          # 安装Cloud Foundry CLI
          wget -q -O cf-cli.deb https://packages.cloudfoundry.org/stable?release=debian64&source=github
          sudo dpkg -i cf-cli.deb
          # 登录并配置CF目标
          cf api ${{ secrets.CF_API }}
          cf auth ${{ secrets.CF_USERNAME }} ${{ secrets.CF_PASSWORD }}
          cf target -o ${{ secrets.CF_ORG }} -s dev
          # 推送应用
          cf push mytestapp_123

方案2:将自定义仓库转为合法GitHub Action

如果你坚持要使用ibpgithub/testserver123@main作为Action,需要在该仓库的main分支根目录创建action.yml文件,示例内容如下:

name: 'Cloud Foundry Deploy'
description: 'Deploy app to Cloud Foundry'
inputs:
  cf_api:
    description: 'Cloud Foundry API endpoint'
    required: true
  cf_username:
    description: 'CF username'
    required: true
  cf_password:
    description: 'CF password'
    required: true
  cf_org:
    description: 'CF organization'
    required: true
  cf_space:
    description: 'CF space'
    required: true
  command:
    description: 'CF command to run'
    required: true

runs:
  using: 'composite'
  steps:
    - name: Install CF CLI
      run: |
        wget -q -O cf-cli.deb https://packages.cloudfoundry.org/stable?release=debian64&source=github
        sudo dpkg -i cf-cli.deb
      shell: bash
    - name: Execute CF command
      run: |
        cf api ${{ inputs.cf_api }}
        cf auth ${{ inputs.cf_username }} ${{ inputs.cf_password }}
        cf target -o ${{ inputs.cf_org }} -s ${{ inputs.cf_space }}
        cf ${{ inputs.command }}
      shell: bash

创建好action.yml并推送到ibpgithub/testserver123仓库后,再修正原main.yml中的setup-python参数错误即可正常使用。

内容的提问来源于stack exchange,提问作者Graphiomaniac

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 05:05:07