Skip to content

Commit

Permalink
Set up Dependabot RBI updates
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Sep 11, 2023
1 parent 9fc9c0a commit 708db57
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/dependabot_update_rbis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Update gem RBIs on Dependabot PRs

on: workflow_call

permissions:
contents: write
pull-requests: write

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
update-gem-rbis:
runs-on: ubuntu-latest
timeout-minutes: 15
if: ${{ github.actor == '"dependabot[bot]"' }}
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Get Ruby version from dev.yml
id: ruby
shell: ruby -ryaml {0}
run: |
exit 1 unless File.exist?("dev.yml")
yaml = YAML.respond_to?(:unsafe_load_file) ? YAML.unsafe_load_file("dev.yml") : YAML.load_file("dev.yml")
ruby_version = yaml["up"]
&.find {|h| Hash === h && h.key?("ruby") }
&.dig("ruby")
.then {|c| Hash === c ? c["version"] : c }
exit 1 unless ruby_version
File.write(ENV.fetch("GITHUB_OUTPUT"), "ruby_version=#{ruby_version}\n", mode: "a")
- uses: ruby/setup-ruby@v1
id: setup
with:
bundler-cache: true
ruby-version: ${{ steps.ruby.outputs.version }}
- name: Update gem RBIs
run: |
bin/tapioca gem
- name: Check for modified files
id: git_modified_files_check
# If there are changes in the sorbet directory, `echo -n` will return true (zero exit code)
run: |
status=$(git status sorbet --porcelain=v1)
echo "changes=$([ -n "$status" ]; echo $?)" >> $GITHUB_OUTPUT
- name: Push changes
if: ${{ steps.git_modified_files_check.outputs.changes == 0 }}
run: |
git config user.name github-actions
git config user.email [email protected]
git add sorbet/*
date="$(date -u +"%Y-%m-%d")"
git commit -m "Update RBI files for gems ${date} [dependabot skip]"
git push
6 changes: 6 additions & 0 deletions .github/workflows/dependabot_update_rbis_run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: Update gem RBIs on Dependabot PRs
on: [pull_request]

jobs:
dependabot_update_rbis:
uses: Shopify/ruby-lsp/.github/workflows/dependabot_update_rbis.yml@main
5 changes: 3 additions & 2 deletions sorbet/tapioca/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ gem:
"psych": "false"
# Add your `gem` command parameters here:
#
# exclude:
# - gem_name
# rdoc causes a failure 'webrick is not found.' when running `tapioca gem`.
exclude:
- rdoc
# doc: true
# workers: 5
dsl:
Expand Down

0 comments on commit 708db57

Please sign in to comment.