Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
98 lines
2.9 KiB
YAML
98 lines
2.9 KiB
YAML
name: Scheduled Checks
|
|
|
|
on:
|
|
schedule:
|
|
# Every monday at 7 AM
|
|
- cron: 0 7 * * 1
|
|
|
|
jobs:
|
|
update:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
steps:
|
|
- name: Checkout 🛎
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
|
|
- name: Set up tools
|
|
uses: ./.github/actions/setup-tools
|
|
with:
|
|
tools: python
|
|
|
|
- name: Set PY
|
|
shell: bash
|
|
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
|
|
|
|
- name: Cache
|
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6
|
|
with:
|
|
path: |
|
|
~/.cache/pre-commit
|
|
~/.cache/pip
|
|
key: pre-commit-${{ env.PY }}-${{ hashFiles('.pre-commit-config.yaml') }}
|
|
|
|
- name: Install pre-commit
|
|
shell: bash
|
|
run: pip install -U pre-commit
|
|
|
|
- name: Run `pre-commit autoupdate`
|
|
shell: bash
|
|
run: pre-commit autoupdate --color=always
|
|
|
|
- name: Generate GitHub App Token
|
|
id: app-token
|
|
uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3
|
|
with:
|
|
app-id: ${{ secrets.COMMIT_BOT_APP_ID }}
|
|
private-key: ${{ secrets.COMMIT_BOT_APP_PRIVATE_KEY }}
|
|
|
|
- name: Create Pull Request
|
|
id: create-pr
|
|
uses: peter-evans/create-pull-request@3ffccacd46053766916f087ce41d627c0b8cf2d1 # v8
|
|
with:
|
|
token: ${{ steps.app-token.outputs.token }}
|
|
commit-message: "Update pre-commit hooks"
|
|
branch: "fix/update-pre-commit-hooks"
|
|
labels: |
|
|
chore
|
|
delete-branch: true
|
|
base: mealie-next
|
|
title: "chore(auto): Update pre-commit hooks"
|
|
body: "Auto-generated by `.github/workflows/scheduled-checks.yml`"
|
|
|
|
- name: Approve PR
|
|
if: steps.create-pr.outputs.pull-request-number
|
|
env:
|
|
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
|
PR_NUMBER: ${{ steps.create-pr.outputs.pull-request-number }}
|
|
REPO: ${{ github.repository }}
|
|
run: |
|
|
APPROVED=$(gh pr view "$PR_NUMBER" \
|
|
--repo "$REPO" \
|
|
--json reviews \
|
|
--jq '.reviews[] | select(.state == "APPROVED") | .id' \
|
|
| wc -l)
|
|
|
|
if [ "$APPROVED" -gt 0 ]; then
|
|
echo "PR already approved"
|
|
exit 0
|
|
fi
|
|
|
|
gh pr review "$PR_NUMBER" \
|
|
--repo "$REPO" \
|
|
--approve \
|
|
--body "Auto-approved: Pre-commit hook updates"
|
|
|
|
- name: Enable auto-merge
|
|
if: steps.create-pr.outputs.pull-request-number
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
PR_NUMBER: ${{ steps.create-pr.outputs.pull-request-number }}
|
|
REPO: ${{ github.repository }}
|
|
run: |
|
|
gh pr merge "$PR_NUMBER" \
|
|
--repo "$REPO" \
|
|
--auto \
|
|
--squash
|