Home > OS >  Github actions: Run step after failed step, but only when scheduled
Github actions: Run step after failed step, but only when scheduled

Time:09-28

I have the following github actions/workflow file below. Behave execution skips the report upload to allure if any test fails or raise an exception. I was able to fix it by using always() on the next step, but unfortunately now the reports are being uploaded even when we are running the tests manually, and we'd like to upload only when scheduled (daily basis). Does anybody know how to achieve this?

...
    - name: Run BDD tests
      env:
        STAGE_EMAIL: ${{ secrets.STAGE_EMAIL }}
        STAGE_PASSWORD: ${{ secrets.STAGE_PASSWORD }}
      run: |
        rm -rf allure-results
        mkdir -p allure-results
        behave --junit --junit-directory allure-results

    - name: Upload test report to Allure
      if: ${{ always() }} && github.event_name == 'schedule'
      env:
        ALLURE_SERVER: ${{ secrets.ALLURE_SERVER }}
      run: |
        python send_test_results.py $GITHUB_REPOSITORY $GITHUB_RUN_ID $ALLURE_SERVER default
...

CodePudding user response:

This expression will do what you want ${{ always() && github.event_name == 'schedule' }}.

  • Related