From 790201ef8027195b69880be8876f0e75793efb16 Mon Sep 17 00:00:00 2001 From: Michel Laterman <82832767+michel-laterman@users.noreply.github.com> Date: Wed, 13 Mar 2024 12:57:04 +0100 Subject: [PATCH] Add post dependabot action to update notice file (#3351) Add post-dependabot action to update NOTICE.txt file. Also include steps to update testing/go.mod and testing/go.sum files if dependabot update would break e2e testing. Copied from elastic/elastic-agent#4012 --- .github/workflows/post-dependabot.yml | 57 +++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/post-dependabot.yml diff --git a/.github/workflows/post-dependabot.yml b/.github/workflows/post-dependabot.yml new file mode 100644 index 000000000..0b4f3750c --- /dev/null +++ b/.github/workflows/post-dependabot.yml @@ -0,0 +1,57 @@ +# Follow-on actions relating to dependabot PRs. In elastic/fleet-server, any changes to +# dependencies contained in go.mod requires the change to be reflected in the +# NOTICE.txt file. When dependabot creates a branch for a go_modules change this +# will update the NOTICE.txt file for that change. +name: post-dependabot + +on: + push: + branches: + - 'dependabot/go_modules/**' + +jobs: + update-notice: + permissions: + # Allow job to write to the branch. + contents: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-go@v4 + with: + go-version-file: .go-version + + - name: run go mod tidy in testing/ + run: cd testing; go mod tidy + + - name: check for modified testing/go.mod or testing/go.sum + id: testing-mod-check + run: echo "modified=$(if git diff-index --quite HEAD -- testing/go.mod testing/go.sum; then echo "false"; else echo "true"; fi)" >> $GITHUB_OUTPUT + + - name: commit testing/go.mod and testing/go.sum files + if: steps.testing-mod-check.outputs.modified == 'true' + run: | + git config --global user.name 'dependabot[bot]' + git config --global user.email 'dependabot[bot]@users.noreply.github.com' + git add testing/go.mod testing/go.sum + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} + git commit -m "Update testing/go.mod and testing/go.sum files" + git push + + - name: update NOTICE.txt + run: make notice + + - name: check for modified NOTICE.txt + id: notice-check + run: echo "modified=$(if git diff-index --quiet HEAD -- NOTICE.txt; then echo "false"; else echo "true"; fi)" >> $GITHUB_OUTPUT + + - name: commit NOTICE.txt + if: steps.notice-check.outputs.modified == 'true' + run: | + git config --global user.name 'dependabot[bot]' + git config --global user.email 'dependabot[bot]@users.noreply.github.com' + git add NOTICE.txt + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} + git commit -m "Update NOTICE.txt" + git push