skip to Main Content

I have a docker compose project. The code doesn’t compile in docker and exits with code 2 but GitHub passes the job and marks as done.

Yml file:

name: Docker Build

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
      - name: Docker build staging
        run: |
          docker compose -f docker-compose.yml up --build -d
  deploy:
    runs-on: [self-hosted, Linux, X64, staging]
    needs: build
    steps:
      - name: Checkout the files
        uses: actions/checkout@v3
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
      - run: |
          
          docker compose -f docker-compose.yml up --build -d

Output:

Failed to solve: executor failed running [/bin/sh -c npm run staging:start]: exit code: 2
#91 CANCELED

2

Answers


  1. Chosen as BEST ANSWER

    If there is anyone who is having this issue, the issue is bash. Actions can't detect errors when you start docker compose in bash script. Instead of this you can type the commands in script directly to the run command.


  2. you can pass de exit code from image to github action throw the command

    
    docker compose -f docker-compose.yml up --build --exit-code-from {image name}
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search