Upload to Codecov #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Upload to Codecov | |
on: | |
workflow_run: | |
workflows: | |
- Checks | |
types: | |
- completed | |
jobs: | |
show-info: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Show event payload | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
txt = JSON.stringify(context.payload.workflow_run, null, 4); | |
core.summary.addCodeBlock(txt, 'json'); | |
core.summary.write() | |
upload: | |
name: Upload coverage reports | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.event.workflow_run.head_repository.full_name }} | |
ref: ${{ github.event.workflow_run.head_sha }} | |
- name: Display codecov.yml file | |
run: cat codecov.yml | |
- name: Download artifacts from triggering workflow | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
ls -lahR | |
gh run download ${{ github.event.workflow_run.id }} --repo ${{ github.repository }} --pattern 'coverage-report-*' | |
ls -lahR | |
- name: Get PR number from triggered event payload | |
if: ${{ github.event.workflow_run.event == 'pull_request' }} | |
id: pr-info | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh run download ${{ github.event.workflow_run.id }} --repo ${{ github.repository }} --name event-payload | |
ls -lah | |
pr_number="$(jq < event.json '.number')" | |
echo "number=$pr_number" >> "$GITHUB_OUTPUT" | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
verbose: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
name: ${{ github.event.workflow_run.id }} | |
job_code: ${{ github.event.workflow_run.name }} | |
override_build: ${{ github.event.workflow_run.id }} | |
override_build_url: ${{ github.event.workflow_run.html_url }} | |
override_commit: ${{ github.event.workflow_run.head_sha }} | |
override_branch: ${{ github.event.workflow_run.head_branch }} | |
override_pr: ${{ github.event.workflow_run.event == 'pull_request' && steps.pr-info.outputs.number || '' }} |