diff --git a/.github/workflows/license.yaml b/.github/workflows/license.yaml index 7aa1a30de8..c88dcadbbe 100644 --- a/.github/workflows/license.yaml +++ b/.github/workflows/license.yaml @@ -1,13 +1,9 @@ name: "Software License Check" on: push: - paths: - - 'go.mod' branches: - main pull_request: - paths: - - 'go.mod' # The branches below must be a subset of the branches above branches: [main] @@ -27,3 +23,5 @@ jobs: run: go install github.com/google/go-licenses@latest - name: Check for forbidden licenses run: make check-licenses + - name: Check if licenses file is updated + run: make update-licenses diff --git a/Makefile b/Makefile index 8f190ea5e1..7c24a3e0db 100644 --- a/Makefile +++ b/Makefile @@ -261,6 +261,12 @@ update-licenses: @echo "Detecting and updating licenses ... please be patient!" go install github.com/google/go-licenses@latest $(shell echo "Module | License URL | License" > THIRD-PARTY-LICENSES.md; echo "---|---|---" >> THIRD-PARTY-LICENSES.md; for i in $$(go list -m all | awk '{print $$1}'); do l=$$(go-licenses csv $$i 2>/dev/null); if [ $$? -ne 0 ]; then continue; fi; echo $$l | tr \, \| | tr ' ' '\n'; done | sort -u >> THIRD-PARTY-LICENSES.md) + $(eval UNCOMMITED_FILES = $(shell git status --porcelain | grep -c THIRD-PARTY-LICENSES.md)) + @if [ $(UNCOMMITED_FILES) != 0 ]; then \ + echo "THIRD-PARTY-LICENSES.md file needs to be updated";\ + git status;\ + exit 1;\ + fi .PHONY: check-licenses check-licenses: