Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Actions Failing

Github Actions were working in my repository till yesterday. I didnt make any changes in .github/workflows/dev.yml file or in DockerFile.

But, suddenly in recent pushes, my Github Actions fail with the error

Setup, Build, Publish, and Deploy

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?

May I know how to fix this

This is the sample .yml file I am using.

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: |

Here's the snippet of error. enter image description here

like image 537
user3665224 Avatar asked Jul 25 '21 07:07

user3665224


People also ask

How do you fail an action in GitHub?

GitHub uses the exit code to set the action's check run status, which can be success or failure . The action completed successfully and other tasks that depends on it can begin. Any other exit code indicates the action failed. When an action fails, all concurrent actions are canceled and future actions are skipped.

How long can a GitHub Action last?

Job execution time - Each job in a workflow can run for up to 6 hours of execution time. If a job reaches this limit, the job is terminated and fails to complete. Workflow run time - Each workflow run is limited to 35 days. If a workflow run reaches this limit, the workflow run is cancelled.

Do GitHub Actions cost money?

GitHub Actions usage is free for both public repositories and self-hosted runners. For private repositories, each GitHub account receives a certain amount of free minutes and storage, depending on the product used with the account.

Do GitHub Actions jobs run in parallel?

You can configure a GitHub Actions workflow to be triggered when an event occurs in your repository, such as a pull request being opened or an issue being created. Your workflow contains one or more jobs which can run in sequential order or in parallel.

How do I know if an action has failed in GitHub?

GitHub displays statuses to indicate passing or failing actions. GitHub uses the exit code to set the action's check run status, which can be success or failure. The action completed successfully and other tasks that depends on it can begin. Any other exit code indicates the action failed.

Can I skip a step in a GitHub action without failing?

GitHub Actions: Skipping a step without failing | An independent mind… I wanted to have a GitHub Action step run that might fail, but if it failed the rest of the steps should still execute and the overall run should be treated as a success. Skip to primary navigation Skip to content Skip to footer An independent mind... Portfolio Posts Categories

What is a GitHub action?

GitHub Actions Automate, customize, and execute your software development workflows right in your repository with GitHub Actions. You can discover, create, and share actions to perform any job you'd like, including CI/CD, and combine actions in a completely customized workflow.

How to restart the GitHub actions workflow?

Restarting the GitHub Actions workflow can be achieved by using the workflow_dispatch event trigger. Info Events that trigger workflows First of all, you need to add the workflow_dispatch event trigger to your GitHub Actions workflow. Info Check out the doctor flow here: release.yml on GitHub.


Video Answer


4 Answers

I fixed it by changing uses value to

  • uses: google-github-actions/setup-gcloud@v0
like image 200
user3665224 Avatar answered Oct 21 '22 00:10

user3665224


There are some changes visit here for details https://github.com/google-github-actions/setup-gcloud#use-google-github-actionssetup-gcloud

steps:
id: gcloud
uses: google-github-actions/setup-gcloud@master

or steps:
id: deploy
uses: google-github-actions/deploy-cloudrun@main

like image 29
athuldevin Avatar answered Oct 21 '22 00:10

athuldevin


For anyone wondering why this is not working anymore, check this notice: https://github.com/google-github-actions/setup-gcloud#-notice

Now each action has its own repo, so you have to change the way you reference Google Cloud Platform actions in your yaml:

steps:
 - id: gcloud
-  uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
+  uses: google-github-actions/setup-gcloud@master
like image 20
Rocío García Luque Avatar answered Oct 21 '22 01:10

Rocío García Luque


I have faced the similar error. When I was trying to call my local workflow from steps level. Apparently GitHub actions support local workflow call from jobs level. I could not call from inside steps.

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
like image 29
avijit bhattacharjee Avatar answered Oct 21 '22 00:10

avijit bhattacharjee