Skip to content

Pre-commit auto-update #58

Pre-commit auto-update

Pre-commit auto-update #58

name: Pre-commit auto-update
# PAT github secret has to be created with repo scope
# add the secret to the repo settings
on:
# every monday
schedule:
- cron: "0 7 * * 1"
# on demand
workflow_dispatch:
#{% raw %}
jobs:
pre-commit-update:
runs-on: ubuntu-latest
name:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update pre-commit hooks
uses: brokenpip3/action-pre-commit-update@0.0.1
with:
github-token: ${{ secrets.PAT }}
- name: Add label
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PAT }}
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: 'auto-update-pre-commit-hooks'
});
if (pullRequests.length > 0) {
const prNumber = pullRequests[0].number;
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
labels: ['automerge']
});
}
#{% endraw %}