Skip to content

Update Gem Version Artifacts #787

Update Gem Version Artifacts

Update Gem Version Artifacts #787

name: Update Gem Version Artifacts
on:
workflow_run:
workflows: ["Dependabot Gem PR Check"]
types:
- completed
jobs:
update-dependencies:
runs-on: ubuntu-latest
if: >-
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.actor.login == 'dependabot[bot]'
# The 'permissions' here apply to the GITHUB_TOKEN, but we'll actually be pushing with the PAT
permissions:
contents: write
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
with:
egress-policy: audit
- name: Checkout Git Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.workflow_run.head_branch }}
# Use the PAT for checkout to ensure proper permissions
token: ${{ secrets.PAT_FOR_PUSHING_AND_TRIGGERING_CI }}
- name: Set up Ruby
uses: ruby/setup-ruby@2a7b30092b0caf9c046252510f9273b4875f3db9 # v1.254.0
with:
ruby-version: "3.4"
bundler-cache: true
cache-version: 2
- name: Update RBS collection
run: bundle exec rbs collection update
- name: Update gem version constraints
run: |
bundle config --local deployment false
script/update_gem_constraints
- name: Commit and push if changed
env:
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
run: |
if [[ -n "$(git status --porcelain)" ]]; then
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add rbs_collection.lock.yaml Gemfile Gemfile.lock *.gemspec
git commit -m "Update gem version artifacts."
# Push using the PAT
git remote set-url origin "https://x-access-token:${{ secrets.PAT_FOR_PUSHING_AND_TRIGGERING_CI }}@github.com/${{ github.repository }}.git"
git push origin "HEAD:$HEAD_BRANCH"
fi