Skip to content

Use a GitHub App for Dependabot merges (#185) #83

Use a GitHub App for Dependabot merges (#185)

Use a GitHub App for Dependabot merges (#185) #83

Workflow file for this run

name: checks
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: prefix-dev/setup-pixi@d3f436a425481402e6a95a1d1fc10331c708cd9e # v0.10.2
- run: pixi run lint
- run: pixi run build-docs
dependabot:
needs: [checks]
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]'
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.sha }}
persist-credentials: false
- uses: prefix-dev/setup-pixi@d3f436a425481402e6a95a1d1fc10331c708cd9e # v0.10.2
with:
# Do not restore executable environments populated by PR checks.
cache: false
- name: Fetch dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check auto-merge policy
id: policy
env:
DEPENDENCIES: ${{ steps.metadata.outputs.updated-dependencies-json }}
run: pixi run check-dependabot-merge
- name: Approve pull request
if: steps.policy.outputs.eligible == 'true'
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create merge token
if: steps.policy.outputs.eligible == 'true'
id: merge-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ vars.ROBOSTACK_BOT_CLIENT_ID }}
private-key: ${{ secrets.ROBOSTACK_BOT_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: write
permission-workflows: write
- name: Enable auto-merge
if: steps.policy.outputs.eligible == 'true'
run: gh pr merge --auto --squash --match-head-commit "$PR_HEAD_SHA" "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
GH_TOKEN: ${{ steps.merge-token.outputs.token }}