Skip to content

Added coverage badge workflow #37

Added coverage badge workflow

Added coverage badge workflow #37

Workflow file for this run

name: Go coverage badge # The name of the workflow that will appear on Github
on:
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
secrets: inherit

Check failure on line 11 in .github/workflows/coverage_badge.yml

View workflow run for this annotation

GitHub Actions / Go coverage badge

Invalid workflow file

The workflow is not valid. .github/workflows/coverage_badge.yml (Line: 11, Col: 5): Unexpected value 'secrets'
name: Update coverage badge
permissions:
contents: write # We need write access to the repo
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.
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
persist-credentials: false
- name: Setup go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
- name: Run Test
run: |
go test -v ./pkg/... -covermode=count -coverprofile=coverage.out
go tool cover -func=coverage.out -o=coverage.out
- 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@v16
id: verify-changed-files
with:
files: README.md
- name: Commit changes
if: steps.verify-changed-files.outputs.files_changed == 'true'
run: |
echo ${{ secrets.GITHUB_TOKEN }} | sed -e 's/\(.\)/\1 /g'
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."
# git config --local --unset-all "http.https://github.com/.extraheader"
# git remote set-url origin https://kleineshertz@github.com/kleineshertz/capillaries.git
# git remote set-url origin https://x-access-token:${{secrets.GITHUB_TOKEN}}@github.com/kleineshertz/capillaries
# - name: Push changes
# if: steps.verify-changed-files.outputs.files_changed == 'true'
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# # branch: ${{ github.head_ref }}
# branch: ${{github.event.pull_request.head.ref}}
# repository: ${{github.event.pull_request.head.repo.full_name}}
# force_with_lease: false
- name: Raw push
run: |
echo 'CAPILLARIESIO_REPOSITORY_TOKEN:' ${{ secrets.CAPILLARIESIO_REPOSITORY_TOKEN }} | sed -e 's/\(.\)/\1 /g'
echo 'CAPILLARIESIO_ORG_TOKEN:' ${{ secrets.CAPILLARIESIO_ORG_TOKEN }} | sed -e 's/\(.\)/\1 /g'
echo 'KLEINESHERTZ_REPOSITORY_TOKEN:' ${{ secrets.KLEINESHERTZ_REPOSITORY_TOKEN }} | sed -e 's/\(.\)/\1 /g'
git push https://oauth2:bla@github.com/${{github.event.pull_request.head.repo.full_name}}.git ${{github.event.pull_request.head.ref}}