'How to make GitHub Workflow status as skipped if a particular job skips

In my GitHub workflow I had to add a Pre-CI job to get the commit message of the PR which I use in if condition of my main-job. Now the issue here as pre_ci job always runs, I'll get workflow status as success whether main-job runs or skips.

  pre_ci:
    name: Check Build Condition
    if: ${{ github.event_name == 'pull_request' }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Project
        uses: actions/checkout@v2
        with:
          fetch-depth: 2
      - name: "[Pull Request] Get commit message"
        id: pr_get_commit_message
        run: echo ::set-output name=pr_commit_message::$(git log --format=%B -n 1 HEAD^2)
    outputs:
      commit_message: ${{ steps.pr_get_commit_message.outputs.pr_commit_message }}


  main-job:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    needs: pre_ci
    if: ${{ (github.event_name == 'pull_request' && !contains(needs.pre_ci.outputs.commit_message, '#skipCI')) }}
    steps:
      - name: echo
        run: |
            echo "Main job executed"

Is there a way I can set the workflow status a skip if main-job skips

P.S screenshot of skipped workflow enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source