Skip to content

Commit 97c312e

Browse files
authored
Merge pull request #2602 from ruby/workflow-update
Add bundle update schedule
2 parents 91c3d4a + f8bcaf2 commit 97c312e

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Scheduled Bundle Update PR
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * 2'
6+
workflow_dispatch:
7+
8+
jobs:
9+
bundle-update:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Ruby
17+
uses: ruby/setup-ruby@v1
18+
with:
19+
ruby-version: '3.4'
20+
21+
- name: Set up git
22+
run: |
23+
git config --global user.name "github-actions[bot]"
24+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
25+
26+
- name: Switch branch
27+
run: |
28+
git switch -c bundle-update-$(date +'%Y%m%d')-$(uuidgen | cut -c1-8)
29+
30+
- name: Install bundler
31+
run: gem install bundler
32+
33+
- name: Run bundle update
34+
run: |
35+
bundle lock --update
36+
git add Gemfile.lock
37+
38+
if git diff --cached --quiet; then
39+
echo "No changes to commit, exiting."
40+
exit 0
41+
fi
42+
43+
git commit -m "bundle update"
44+
echo "has_update=true" >> $GITHUB_ENV
45+
46+
- name: Push branch
47+
if: env.has_update == 'true'
48+
run: git push origin HEAD
49+
50+
- name: Create Pull Request
51+
if: env.has_update == 'true'
52+
env:
53+
GH_TOKEN: ${{ github.token }}
54+
run: |
55+
gh pr create \
56+
--title "bundle update `/Gemfile`" \
57+
--body "Automated bundle update" \
58+
--head "$(git rev-parse --abbrev-ref HEAD)" \
59+
--base "main"

0 commit comments

Comments
 (0)