Codecov Publish #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: Codecov Publish | |
# Due to the behavior of workflow_run, changes to this file will | |
# only be reflected once it is pushed up to the `default` (main) branch | |
# | |
# It is recommended to test changes to this file by pushing to the default branch | |
# on a fork and evaluating the correctness of the action execution | |
on: | |
workflow_run: | |
workflows: [CI] | |
types: | |
- completed | |
jobs: | |
publish-codecov: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Workflow Info | |
uses: actions/download-artifact@v4 | |
with: | |
# Needed for cross run downloading | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
name: workflow-info | |
run-id: ${{ github.event.workflow_run.id }} | |
- name: Set Environment Variables from JSON | |
run: | | |
ls | |
# Read the JSON file and export each key-value pair as an environment variable | |
for key in $(jq -r 'keys[]' ./workflow-info.json); do | |
value=$(jq -r --arg key "$key" '.[$key]' ./workflow-info.json) | |
echo "workflow-info_$key=$value" | |
echo "workflow-info_$key=$value" >> $GITHUB_ENV | |
done | |
- name: Download Coverage Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
# Needed for cross run downloading | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path: ./coverage-reports | |
pattern: coverage-reports-* | |
run-id: ${{ github.event.workflow_run.id }} | |
- name: Upload coverage report | |
uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true | |
files: /**/coverage-reports/**/*.* | |
flags: unittests | |
override_branch: ${{ env.workflow-info_branch }} | |
override_commit: ${{ env.workflow-info_commit }} | |
override_pr: ${{ env.workflow-info_pr_number }} | |
commit_parent: ${{ env.workflow-info_commit_parent }} | |
override_build_url: ${{ env.workflow-info_build_url }} | |
override_build: ${{ env.workflow-info_build }} | |
token: ${{ secrets.CODECOV_TOKEN }} | |
verbose: true |