Success() does not works

I use success() in my workflows, but after the previous task was cancelled, success did not cancel the trigger, and caused the error in the subsequent steps?
Is there something wrong with me?

my_workflows.yml

      - name: setup and build
        if: steps.comparison1.outputs.result == 'true'
        run: |
          npm install
          npm run build-update

      - name: Get menifest version
        if: success()
        uses: actions/github-script@v3.0.0
        id: get-menifest-version
        with:
          result-encoding: string
          script: |
            const manifest = require(`${process.env.GITHUB_WORKSPACE}/build/manifest.json`);
            return manifest.version;

and the performance:

Since the last step that reported a status was a success I guess it continued this one instead of skipping.

If it’s really a problem it seems you should check the outcome of each step, or check for cancelled:

But in docs:

success
Returns true when none of the previous steps have failed or been canceled.

Context and expression syntax for GitHub Actions - GitHub Docs

Could you link the workflow run?

I tested the judgment using the outcome and it was successful, but I am still confused about why success() cannot judge success. This is the record at the time.

yi-Xu-0100/soulsign-chrome@09a106b (github.com)

I’m not so sure your cancel was actually processed at all. The “setup and build” step actually says it was skipped, which I believe means that the condition steps.comparison1.outputs.result == 'true' was not met.

Subsequent steps were skipped cause success() wasn’t true after “Get menifest version” failed. (“Get menufest version” failed because success was still true and the file it needed wasn’t present. It doesn’t look like there’s a way to check skipped steps … at least not as a success/failure/cancelled condition [that I’ve seen]).

Note, not sure if you care but there’s a few occurrences of "menifest’ which should likely be “manifest” :wink:

Thank you for your reply. You mean that the success status judged by Get manifest version comes from Compare version, and setup and build is skipped directly?

I think it may be caused by such a situation. Is there any judgment of skip state? I only saw the ones that were judged to be cancelled. To determine the state of the previous step, you need to add an id to each state and write a long judgment formula, which is too verbose.

Finally, thank you for pointing out my spelling mistakes, I am always so careless and I will fix this. :smiley:

Yes I think that’s what’s going on.

I just did a bit more quick reading, I think you could do something like:

      - name: setup and build
        id: build
        if: steps.comparison1.outputs.result == 'true'
        run: |
          npm install
          npm run build-update
      - name: Get menifest version
        if: success() && steps.build.conclusion != 'skipped'
        uses: actions/github-script@v3.0.0
        id: get-menifest-version
        with:
          result-encoding: string
          script: |
            const manifest = require(`${process.env.GITHUB_WORKSPACE}/build/manifest.json`);
            return manifest.version;

(^ Add id: build to the setup and build step. Add a secondary condition to the Get manifest version step: && steps.build.conclusion != 'skipped'.)

No problem, happens to all of us.

1 Like

Because the subsequent steps to publish the release also need the support of the previous steps, I have judged the subsequent related steps as an outcome, and there is no problem with the current tests.
Thank you for your suggestions and help. :smiley: