Debian Codegraph @

.github/workflows/dependencies.yaml

raw
1 name: License Check
2
3 on:
4 push:
5 paths:
6 - 'go.mod'
7 branches:
8 - main
9
10 jobs:
11 license-check:
12 runs-on: ubuntu-latest
13
14 env:
15 BRANCH_NAME: update-report-branch-${{ github.run_id }}
16
17 steps:
18 - name: Checkout repository
19 uses: actions/checkout@v6
20 with:
21 fetch-depth: 0 # Fetch all history for all branches and tags
22
23 - name: Set up Go
24 uses: actions/setup-go@v6
25 with:
26 go-version: '1.26'
27
28 - name: Install go-licenses
29 run: go install github.com/google/go-licenses@latest
30 # We need this step because of test dependencies and how they are handled in nats.go
31 - name: Run go mod tidy
32 run: go mod tidy
33 - name: Run license check
34 run: go-licenses report ./... --template dependencies.tpl > dependencies.md
35
36 - name: Configure git
37 run: |
38 git config user.name 'github-actions[bot]'
39 git config user.email 'github-actions[bot]@users.noreply.github.com'
40
41 - name: Check for changes
42 id: git_diff
43 run: |
44 git fetch
45 git diff --exit-code dependencies.md || echo "has_changes=true" >> $GITHUB_ENV
46
47 - name: Commit changes
48 if: env.has_changes == 'true'
49 run: |
50 git checkout -b "$BRANCH_NAME"
51 git add dependencies.md
52 git commit -m "Update dependencies.md"
53 git push -u origin "$BRANCH_NAME"
54
55 - name: Create Pull Request
56 if: env.has_changes == 'true'
57 env:
58 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59 run: |
60 gh pr create --title "Update dependencies.md" --body "This PR updates the dependencies report" --head "$BRANCH_NAME" --base main
61