Skip to content

Commit 62236d3

Browse files
authored
github-action: update dependabot PRs with NOTICE.txt (#458)
1 parent 3b1f677 commit 62236d3

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
# Dependabot Pull Requests are not updating the NOTICE.txt file, which causes the lint job to fail.
3+
# This workflow will checkout the dependabot PR, update the NOTICE.txt file, and push the changes back to the PR.
4+
name: update-dependabot-pr
5+
6+
on:
7+
push:
8+
branches:
9+
- dependabot/go_modules/**
10+
paths-ignore:
11+
- NOTICE.txt
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
update-dependabot-pr:
18+
permissions:
19+
contents: write
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: actions/setup-go@v5
24+
with:
25+
go-version-file: go.mod
26+
- name: Update NOTICE.txt
27+
run: make NOTICE.txt
28+
# inspired by https://gist.github.com/swinton/03e84635b45c78353b1f71e41007fc7c
29+
- name: Commit changes (signed)
30+
run: |
31+
export BRANCH=${GITHUB_REF#refs/heads/}
32+
export SHA=$(git rev-parse "$BRANCH:$FILE_TO_COMMIT")
33+
gh api --method PUT "/repos/${REPO}/contents/$FILE_TO_COMMIT" \
34+
--field message="Update $FILE_TO_COMMIT" \
35+
--field content=@<(base64 -i $FILE_TO_COMMIT) \
36+
--field sha="${SHA}" \
37+
--field branch="${BRANCH}"
38+
env:
39+
FILE_TO_COMMIT: NOTICE.txt
40+
REPO: ${{ github.repository }}
41+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)