Skip to content

chore: Reuse API update - Migration from dep5 file to TOML file. #102

chore: Reuse API update - Migration from dep5 file to TOML file.

chore: Reuse API update - Migration from dep5 file to TOML file. #102

name: Generate code coverage badge
on:
pull_request:
branches:
- main
jobs:
variables:
name: Variables
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: golangci version
uses: mikefarah/yq@v4.33.1
id: golangci_version
with:
cmd: yq '.golangci_version' .buildvars.yml
- name: golang version
uses: mikefarah/yq@v4.33.1
id: go_version
with:
cmd: yq '.go_version' .buildvars.yml
outputs:
go_version: ${{ steps.go_version.outputs.result }}
golangci_version: ${{ steps.golangci_version.outputs.result }}
test:
runs-on: ubuntu-latest
name: Update coverage badge
needs: [variables]
steps:
- uses: actions/checkout@v3
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.
- uses: actions/setup-go@v4
with:
go-version: ${{ needs.variables.outputs.go_version }}
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Test
run: make test
- name: Go Coverage Badge # Pass the `coverage.out` output to this action
uses: tj-actions/coverage-badge-go@v2
with:
filename: coverage.out
- name: Verify Changed files
uses: tj-actions/verify-changed-files@v17
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 "action@github.com"
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: ${{ github.token }}
branch: ${{ github.head_ref }}