EnricoMi / publish-unit-test-result-action

GitHub Action to publish unit test results on GitHub
Apache License 2.0
625 stars 184 forks source link

Commit Status with manual workflow #605

Open sebastien-savalle opened 5 months ago

sebastien-savalle commented 5 months ago

Hello,

First of all, thanks a lot for publishing this github action which is really useful. This works like a charm with pull request event, but I found a small issue when using manual workflow. In such case, the comment is correctly published to the PRs related to the selected branch, but the commit status is missing.

As a workaround (see below example), I retrieve the step outcome of your action and post it manually. Would it be possible to also support commit status for manual workflow ?

Thanks a lot, Sebastien

- name: Publish report
  id: internal_api_report
  uses: EnricoMi/publish-unit-test-result-action@v2
  if: always()
  with:
    files: |
      !packages/api-tests/**/node_modules/**
      ./packages/api-tests/reports/internal-api.xml
    check_name: "Internal API Tests Result"
    action_fail: true
    action_fail_on_inconclusive: true
- name: Set Internal API Commit Status
  uses: actions/github-script@v7
  if: always()
  env:
    GITHUB_TOKEN: ${{ github.token }}
    RESULT_STATE: ${{ steps.internal_api_report.outcome }}
  with:
    script: |
      github.rest.repos.createCommitStatus({
        owner: context.repo.owner,
        repo: context.repo.repo,
        sha: context.sha,
        state: process.env.RESULT_STATE,
        description: process.env.RESULT_STATE,
        context: 'internal-api'
      })
EnricoMi commented 3 months ago

Can you provide an example commit / workflow run in a public repo?