Search code examples
github-actionskubectl

GitHub Actions fails with: "An error occurred trying to start process '/usr/bin/bash' with working directory"


The Error from GitHub:

An error occurred trying to start process '/usr/bin/bash' with working directory '/home/runner/work/myproject-api/myproject-api/app'. No such file or directory

My Workflow File:

name: Docker Build and Push to Docker Hub and ghcr.io

on:
  push:
    branches:
      - 'feature/auto-deploy-dev'

defaults:
  run:
    working-directory: app

jobs:
  docker:
    runs-on: ubuntu-latest
    steps:

      - name: Checkout
        uses: actions/checkout@v2

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Login to DockerHub
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.SECRET }}
          password: ${{ secrets.TOKEN }}

      - name: Build and push
        uses: docker/build-push-action@v2
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
          file: Dockerfile
          tags: |
            repo/project:latest

      - name: Checkout
        uses: actions/checkout@v2

      - name: KubeCtl Command
        uses: tale/kubectl-action@v1
        with:
          base64-kube-config: ${{ secrets.KUBECONFIG }}
      - run: kubectl get pods -n myNamespace

Solution

  • I removed the "defaults.run.working-directory: app" and now it works for all steps. The error messages are gone.