Github 操作失败

use*_*224 13 git yaml github docker github-actions

直到昨天,Github Actions 还在我的存储库中工作。我没有在 .github/workflows/dev.yml 文件或 DockerFile 中做任何更改。

但是,突然在最近的推送中,我的 Github Actions 因错误而失败

设置、构建、发布和部署

Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under
'/home/runner/work/_actions/GoogleCloudPlatform/github-actions/master/setup-gcloud'.
Did you forget to run actions/checkout before running your local
action?
Run Code Online (Sandbox Code Playgroud)

我可以知道如何解决这个问题吗

这是我正在使用的示例 .yml 文件。

name: Release to Development

on:
  push:
    branches:
      - 'master'
jobs:
  setup-build-publish-deploy:
    name: Setup, Build, Publish, and Deploy
    runs-on: ubuntu-latest
    steps:

    - name: Checkout
      uses: actions/checkout@v2

    # Setup gcloud CLI
    - uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
      with:
        version: '270.0.0'
        service_account_email: ${{ secrets.GCLOUD_EMAIL_DEV }}
        service_account_key: ${{ secrets.GCLOUD_AUTH_DEV }}

    # Configure docker to use the gcloud command-line tool as a credential helper
    - run: |
        # Set up docker to authenticate
        # via gcloud command-line tool.
        gcloud auth configure-docker

    # Build the Docker image
    - name: Build
      run: |
        docker build -t "$REGISTRY_HOSTNAME"/"$GKE_PROJECT"/"$IMAGE":"$GITHUB_SHA" \
          --build-arg GITHUB_SHA="$GITHUB_SHA" \
          --build-arg GITHUB_REF="$GITHUB_REF" .

    # Push the Docker image to Google Container Registry
    - name: Publish
      run: |
        docker push $REGISTRY_HOSTNAME/$GKE_PROJECT/$IMAGE:$GITHUB_SHA

    # Set up kustomize
    - name: Set up Kustomize
      run: |
        curl -o kustomize --location https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
        chmod u+x ./kustomize

    # Deploy the Docker image to the GKE cluster
    - name: Deploy
      run: |
Run Code Online (Sandbox Code Playgroud)

这是错误的片段。 在此处输入图片说明

use*_*224 18

我通过将uses值更改为

  • uses: google-github-actions/setup-gcloud@master

  • 我会编辑这个答案,在末尾包含“@v0”,因为谷歌将在今年的某个时候将其基本分支重命名为“main”,并且所有使用“@master”的工作流程都将中断。来源:https://github.com/google-github-actions/setup-gcloud#-notice (2认同)

avi*_*jee 8

我也遇到过类似的错误。当我尝试从步骤级别调用本地工作流程时。显然,GitHub 操作支持从作业级别调用本地工作流程。我无法从楼梯内打电话。

name: Build and Deploy

on:
  push:
    branches: [dev]

permissions:
  id-token: write
  contents: read

jobs:
  build-and-publish:
    steps:

    - name: Checkout
      uses: actions/checkout@v2

    - name: test local call from steps # this do not work
      if: github.ref_name == 'dev'       
      uses: ./.github/workflows/deploy.yml # this is from steps level
        with:
          devops-bucket: bucket-name
          role: iam role for the job

  dev: # this worked well
    if: github.ref_name == 'dev'
    uses: ./.github/workflows/deploy.yml # this is jobs level
    with:
      devops-bucket: bucket-name
      role: iam role for the job
Run Code Online (Sandbox Code Playgroud)

  • 不过这个答案很有用。我遇到了类似的问题,看到这一点既让我了解了可重用工作流程和操作之间的区别,也让我了解了调用可重用工作流程的正确方法(作为他们自己的工作,而不是像调用操作一样) (6认同)

小智 6

有一些更改,请访问此处了解详细信息https://github.com/google-github-actions/setup-gcloud#use-google-github-actionssetup-gcloud

步骤:
id:gcloud
使用:google-github-actions/setup-gcloud@master

或步骤:
id:部署
使用:google-github-actions/deploy-cloudrun@main