Update gem RBIs on Dependabot PRs #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update gem RBIs on Dependabot PRs | |
on: | |
workflow_dispatch: | |
workflow_call: | |
inputs: | |
dependency_setup_command: | |
description: A bash script that sets up manually-required dependencies | |
type: string | |
required: false | |
tapioca_env_vars: | |
description: A space-delimited list of environment variables and their values, to be passed to the `tapioca gem` command | |
type: string | |
required: false | |
valid_actors: | |
description: A stringified list of GitHub actors that can trigger this job | |
type: string | |
default: '["dependabot[bot]"]' | |
required: false | |
secrets: | |
BUNDLER_GITHUB_TOKEN: | |
required: false | |
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: 30 | |
if: ${{ contains(fromJson(inputs.valid_actors), github.actor) }} | |
steps: | |
- name: Checkout PR branch | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
# - name: Get Ruby version | |
# do we need this? | |
- name: Set up any manually specified dependencies | |
if: ${{ inputs.dependency_setup_command != '' }} | |
run: ${{ inputs.dependency_setup_command }} | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
- uses: ruby/setup-ruby@v1 | |
id: setup | |
with: | |
bundler-cache: true | |
ruby-version: ${{ steps.ruby.outputs.version }} | |
- name: Ruby setup error details | |
if: ${{ failure() && steps.setup.conclusion == 'failure' }} | |
run: | | |
echo "A failure during the Ruby setup step could indicate that the permissions" \ | |
" for this repo are not configured correctly." \ | |
exit 1 | |
- name: Update gem RBIs | |
run: | | |
${{ inputs.tapioca_env_vars }} 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 |