diff --git a/.github/workflows/update-dependabot-pr.yml b/.github/workflows/update-dependabot-pr.yml index 0b2d64a511d..23756804304 100644 --- a/.github/workflows/update-dependabot-pr.yml +++ b/.github/workflows/update-dependabot-pr.yml @@ -25,9 +25,16 @@ jobs: go-version-file: go.mod - name: Update NOTICE.txt run: make notice - - run: | - git config --global user.name 'dependabot[bot]' - git config --global user.email 'dependabot[bot]@users.noreply.github.com' - git diff --exit-code NOTICE.txt || (git add NOTICE.txt && git commit -am "Update NOTICE.txt") - git push - + # inspired by https://gist.github.com/swinton/03e84635b45c78353b1f71e41007fc7c + - name: Commit changes (signed) + run: | + export BRANCH=${GITHUB_REF#refs/heads/} + export SHA=$(git rev-parse "$BRANCH:$FILE_TO_COMMIT") + gh api --method PUT "/repos/${REPO}/contents/$FILE_TO_COMMIT" \ + --field message="Update $FILE_TO_COMMIT" \ + --field content="@<(base64 -i $FILE_TO_COMMIT)" \ + --field sha="${SHA}" \ + --field branch="${BRANCH}" + env: + FILE_TO_COMMIT: NOTICE.txt + REPO: ${{ github.repository }}