Fez Vrasta
Fez Vrasta

Reputation: 14835

Run action if artifact upload is run or skip?

I'm trying to run two different job steps depending by the result of a @actions/upload-artifact@v2 action. The problem is that none of them run for some reason.

What's wrong with my configuration?

jobs:
  test:
    runs-on: ubuntu-20.04
    container: buildkite/puppeteer
    steps:
      - uses: actions/checkout@v2
      - run: yarn test
      - name: artifacts
        uses: actions/upload-artifact@v2
        id: archive
        if: failure() # Only upload if the build failed
        with:
          name: diff
          path: __diff_output__

      - name: run if nothing was archived
        if: steps.archive.conclusion == 'skip'
        run: echo not archived

      - name: run if something was archived
        if: steps.archive.conclusion == 'success'
        run: echo archived

Upvotes: 1

Views: 564

Answers (1)

Krzysztof Madej
Krzysztof Madej

Reputation: 40879

You were close. You need to use outcome

jobs:
  test:
    runs-on: ubuntu-20.04
    container: buildkite/puppeteer
    steps:
      - uses: actions/checkout@v2
      - run: yarn test
      - name: artifacts
        uses: actions/upload-artifact@v2
        id: archive
        if: failure() # Only upload if the build failed
        with:
          name: diff
          path: __diff_output__

      - name: run if nothing was archived
        if: steps.archive.outcome == 'skipped'
        run: echo not archived

      - name: run if something was archived
        if: steps.archive.outcome == 'success'
        run: echo archived

And skipped instead of skip.

Upvotes: 2

Related Questions