Skip to content

revisi CI/CD

revisi CI/CD #2

Workflow file for this run

name: Check Unused Functions
on:
pull_request:
paths:
- '**.go'
push:
branches: [ main ]
jobs:
unused-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Install dependencies
run: go mod download
- name: Run unused function scan
run: |
go run main.go unused ./ > unused-report.txt
cat unused-report.txt
- name: Fail if unused functions found
run: |
if grep -q unused-report.txt; then
echo "::error ::Found unused functions!"
exit 1
fi
- name: Comment unused functions on PR
if: github.event_name == 'pull_request' && failure()
uses: marocchino/sticky-pull-request-comment@v2
with:
header: unused-functions
message: |
**Unused Function(s) Detected**
```
$(cat unused-report.txt)
```
> Please remove unused code or add to ignore list if necessary.