Skip to content

A platform for community discussion. Free, open, simple.

DEV: Normalize Gemfile.lock in Dependabot PRs (#40464)

Jarek Radosz7819ac75c914
diff --git a/.github/workflows/dependabot-bundler-checksums.yml b/.github/workflows/dependabot-bundler-checksums.yml
new file mode 100644
index 00000000000..1802fdd6777
--- /dev/null
+++ b/.github/workflows/dependabot-bundler-checksums.yml
@@ -0,0 +1,46 @@
+name: Bundler checksums on Dependabot PRs
+
+on:
+ push:
+ branches:
+ - "dependabot/bundler/**/*"
+ paths:
+ - "Gemfile.lock"
+
+permissions:
+ contents: write
+
+jobs:
+ normalize:
+ name: Normalize
+ if: github.actor == 'dependabot[bot]'
+ runs-on: ${{ (github.repository_owner == 'discourse' && 'cdck-linux-8-core') || 'ubuntu-latest' }}
+ container: discourse/discourse_test:release
+
+ steps:
+ - name: Set working directory owner
+ run: chown root:root .
+
+ - uses: actions/checkout@v6
+ with:
+ fetch-depth: 1
+ token: ${{ secrets.GH_PUSH_TOKEN }}
+
+ # Dependabot writes a newer `bundler` checksum than `BUNDLED WITH`; rewrite
+ # it with the image's bundler so the linting check passes. See
+ # https://github.com/ruby/rubygems/issues/9512
+ - name: Normalize Gemfile.lock
+ env:
+ BUNDLE_FROZEN: "false"
+ BUNDLE_DEPLOYMENT: "false"
+ run: |
+ bundle lock --add-checksums
+ bundle lock --normalize-platforms
+
+ - name: Git push
+ run: |
+ git config --global user.email "[email protected]"
+ git config --global user.name "discoursebot"
+ git add Gemfile.lock
+ git status
+ git commit -m "Normalize Gemfile.lock checksums [dependabot skip]" && git push || echo "done"