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

GitHub Actions工作流文件无效:YAML语法错误排查求助

问题分析与修复

错误根源

  1. 缩进层级错误:你的env和steps配置没有缩进在build_push_grc这个job的层级下,而是被当成了jobs的直接子项,这违反了GitHub Actions YAML的结构规范,导致第15行(env所在行)语法报错。
  2. 拼写错误:runs_on: unbuntu-latest中的unbuntu拼写错误,正确应为ubuntu-latest。

修正后的完整YAML代码

---
name: Build and push python code to gcp with github actions
on:
  push:
    branches:
      - main
jobs:
  build_push_grc:
    name: Build and push to gcr
    runs_on: ubuntu-latest
    env:
      IMAGE_NAME: learning_cicd
      PROJECT_ID: personal-370316
    steps:
      - name: Checkoutstep
        uses: actions/checkout@v2
      - uses: google-github-actions/setup-gcloud@master
        with:
          service_account_key: ${{ secrets.SERVICE_ACCOUNT_KEY}}
          project_id: ${{ env.PROJECT_ID }}
          export_default_credentials: true
      
      - name: Build Docker Image
        run: docker build -t $IMAGE_NAME:latest .
      
      - name: Configure Docker Client
        run: |-
          gcloud auth configure-docker --quiet
      
      - name: Push Docker Image to Container Registry (GCR)
        env:
          GIT_TAG: v0.1.0
        run: |-
          docker tag $IMAGE_NAME:latest gcr.io/$PROJECT_ID/$IMAGE_NAME:latest
          docker tag $IMAGE_NAME:latest gcr.io/$PROJECT_ID/$IMAGE_NAME:$GIT_TAG
          docker push gcr.io/$PROJECT_ID/$IMAGE_NAME:latest
          docker push gcr.io/$PROJECT_ID/$IMAGE_NAME:$GIT_TAG

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.02 02:51:56