chore(deps): update codecov/codecov-action action to v5 #714
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: Generate code coverage badge | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
if: | | |
( | |
github.actor != 'dependabot[bot]' && | |
github.actor != 'dependabot' && | |
github.event.pull_request.head.repo.fork != 'true' | |
) | |
name: Update coverage badge | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token. | |
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. | |
- name: Setup go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
- uses: actions/cache@v4 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Run Test | |
run: | | |
go test -v ./... -covermode=count -coverprofile=coverage.out | |
go tool cover -func=coverage.out -o=coverage2.out | |
- name: Run codacy-coverage-reporter | |
uses: codacy/codacy-coverage-reporter-action@v1 | |
with: | |
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
coverage-reports: coverage.out | |
force-coverage-parser: go | |
language: go | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v5 | |
- name: Go Coverage Badge | |
uses: tj-actions/coverage-badge-go@v2 | |
with: | |
filename: coverage2.out | |
- name: Verify Changed files | |
uses: tj-actions/verify-changed-files@v20 | |
id: verify-changed-files | |
with: | |
files: README.md | |
- name: Commit changes | |
if: steps.verify-changed-files.outputs.files_changed == 'true' | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add README.md | |
git commit -m "chore: Updated coverage badge." | |
- name: Push changes | |
if: steps.verify-changed-files.outputs.files_changed == 'true' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.PAT_TOKEN }} | |
branch: ${{ github.head_ref }} |