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
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.
you can pass de exit code from image to github action throw the command