Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/check-ruby-versions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Check for New Ruby Versions

on:
schedule:
- cron: '0 2 * * *' # Daily at 2 AM UTC
workflow_dispatch: # Allow manual triggers

permissions:
contents: write
pull-requests: write
issues: write

jobs:
check-versions:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true

- name: Check for new versions and create PR
id: check-and-create
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUMBER=$(bin/check-and-create-pr)

if [ -n "$PR_NUMBER" ]; then
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
fi

- name: Enable auto-merge
if: steps.check-and-create.outputs.pr_number != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Enabling auto-merge for PR #${{ steps.check-and-create.outputs.pr_number }}..."
gh pr merge ${{ steps.check-and-create.outputs.pr_number }} --auto --squash

- name: Create issue on failure
if: failure()
uses: actions/github-script@v7
with:
script: |
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '🔴 Ruby Version Check Failed',
body: `The automated Ruby version check workflow failed.

**Run:** ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}

**Job:** ${context.job}

Please check the workflow logs for details.`,
labels: ['automation', 'bug', 'ruby-versions']
});
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
source "https://rubygems.org"

gem "minitest"
gem "mocha"
gem "octokit"
gem "rake"
gem "webmock"
53 changes: 53 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,23 +1,76 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.8)
public_suffix (>= 2.0.2, < 8.0)
bigdecimal (4.0.1)
crack (1.0.1)
bigdecimal
rexml
faraday (2.14.0)
faraday-net_http (>= 2.0, < 3.5)
json
logger
faraday-net_http (3.4.2)
net-http (~> 0.5)
hashdiff (1.2.1)
json (2.18.0)
logger (1.7.0)
minitest (6.0.1)
prism (~> 1.5)
mocha (3.0.1)
ruby2_keywords (>= 0.0.5)
net-http (0.9.1)
uri (>= 0.11.1)
octokit (10.0.0)
faraday (>= 1, < 3)
sawyer (~> 0.9)
prism (1.9.0)
public_suffix (7.0.2)
rake (13.3.1)
rexml (3.4.4)
ruby2_keywords (0.0.5)
sawyer (0.9.3)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
uri (1.1.1)
webmock (3.26.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)

PLATFORMS
aarch64-linux
ruby

DEPENDENCIES
minitest
mocha
octokit
rake
webmock

CHECKSUMS
addressable (2.8.8) sha256=7c13b8f9536cf6364c03b9d417c19986019e28f7c00ac8132da4eb0fe393b057
bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7
crack (1.0.1) sha256=ff4a10390cd31d66440b7524eb1841874db86201d5b70032028553130b6d4c7e
faraday (2.14.0) sha256=8699cfe5d97e55268f2596f9a9d5a43736808a943714e3d9a53e6110593941cd
faraday-net_http (3.4.2) sha256=f147758260d3526939bf57ecf911682f94926a3666502e24c69992765875906c
hashdiff (1.2.1) sha256=9c079dbc513dfc8833ab59c0c2d8f230fa28499cc5efb4b8dd276cf931457cd1
json (2.18.0) sha256=b10506aee4183f5cf49e0efc48073d7b75843ce3782c68dbeb763351c08fd505
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
minitest (6.0.1) sha256=7854c74f48e2e975969062833adc4013f249a4b212f5e7b9d5c040bf838d54bb
mocha (3.0.1) sha256=74f82c5959e3df6cfa2757d60aa420dcb151ac7c5eb61dcebf1cd4e368ed7469
net-http (0.9.1) sha256=25ba0b67c63e89df626ed8fac771d0ad24ad151a858af2cc8e6a716ca4336996
octokit (10.0.0) sha256=82e99a539b7637b7e905e6d277bb0c1a4bed56735935cc33db6da7eae49a24e8
prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
public_suffix (7.0.2) sha256=9114090c8e4e7135c1fd0e7acfea33afaab38101884320c65aaa0ffb8e26a857
rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142
ruby2_keywords (0.0.5) sha256=ffd13740c573b7301cf7a2e61fc857b2a8e3d3aff32545d6f8300d8bae10e3ef
sawyer (0.9.3) sha256=0d0f19298408047037638639fe62f4794483fb04320269169bd41af2bdcf5e41
uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6
webmock (3.26.1) sha256=4f696fb57c90a827c20aadb2d4f9058bbff10f7f043bd0d4c3f58791143b1cd7

BUNDLED WITH
4.0.3
4 changes: 2 additions & 2 deletions bin/add-ruby-version
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative "../lib/add_ruby_version"
require_relative "../lib/commands/add_ruby_version"

if ARGV.length != 1
warn "Usage: bin/add-ruby-version <ruby-version>"
warn "Example: bin/add-ruby-version 3.4.5"
exit 1
end

result = AddRubyVersion.call(ARGV[0], working_dir: Dir.pwd)
result = Commands::AddRubyVersion.call(ARGV[0], working_dir: Dir.pwd)
exit(result[:success] ? 0 : 1)
72 changes: 72 additions & 0 deletions bin/check-and-create-pr
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# Check for new Ruby versions and create a PR if found
#
# Usage:
# bin/check-and-create-pr [options]
#
# Options:
# --dry-run Check for versions but don't create a PR
# --help Show this help message
#
# Environment variables:
# GITHUB_TOKEN - GitHub token for API requests (optional, but recommended)
#
# Exit codes:
# 0 - Success (PR created or no new versions)
# 1 - Error occurred

require_relative "../lib/commands/check_and_create_pr"

def print_help
puts <<~HELP
Check for new Ruby versions and create a PR if found

Usage:
bin/check-and-create-pr [options]

Options:
--dry-run Check for versions but don't create a PR
--help Show this help message

Environment variables:
GITHUB_TOKEN - GitHub token for API requests (optional, but recommended)

Examples:
bin/check-and-create-pr # Check and create PR
bin/check-and-create-pr --dry-run # Check only, don't create PR
GITHUB_TOKEN=xxx bin/check-and-create-pr # Use specific token
HELP
end

# Parse arguments
dry_run = false
ARGV.each do |arg|
case arg
when "--dry-run"
dry_run = true
when "--help", "-h"
print_help
exit 0
else
warn "Unknown option: #{arg}"
print_help
exit 1
end
end

# Run the check and create PR
# Use stderr for log messages so stdout only contains the PR number (for CI capture)
result = Commands::CheckAndCreatePR.call(
working_dir: Dir.pwd,
output: $stderr,
dry_run: dry_run
)

# Output PR number to stdout if created (for use in CI)
if result[:pr_created] && result[:pr_number]
puts result[:pr_number]
end

exit(result[:success] ? 0 : 1)
Loading