mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-18 05:21:35 +00:00
77 lines
2.4 KiB
YAML
77 lines
2.4 KiB
YAML
name: Pre-commit auto-update
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 18 * * 1-4'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
update-pre-commit:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Update dependencies
|
|
run: |
|
|
set -x
|
|
python -m pip install --upgrade pip
|
|
pip install pre-commit
|
|
pre-commit autoupdate
|
|
|
|
- name: Gather changes
|
|
id: gather-changes
|
|
run: |
|
|
git diff --color
|
|
changes="$(git diff)"
|
|
delimiter="$(openssl rand -hex 8)"
|
|
echo "changes<<${delimiter}" >> "${GITHUB_OUTPUT}"
|
|
echo "${changes}" >> "${GITHUB_OUTPUT}"
|
|
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
|
|
|
|
- name: Create or update pull request
|
|
id: cpr
|
|
uses: peter-evans/create-pull-request@v5
|
|
with:
|
|
commit-message: Update pre-commit dependencies
|
|
labels: cleanup-no-release-required, dependencies, github_actions
|
|
title: Update pre-commit dependencies
|
|
body: |
|
|
```diff
|
|
${{ steps.gather-changes.outputs.changes }}
|
|
```
|
|
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
|
committer: GitHub <noreply@github.com>
|
|
delete-branch: true
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.PHP_CURL_CLASS_BOT_TOKEN }}
|
|
|
|
- name: Pull request created or updated
|
|
if: ${{ steps.cpr.outputs.pull-request-number }}
|
|
run: |
|
|
echo "Pull request: ${{ steps.cpr.outputs.pull-request-url }}"
|
|
|
|
- name: Enable auto-merge for pull request
|
|
if: ${{ steps.cpr.outputs.pull-request-number }}
|
|
run: |
|
|
gh pr merge --auto --merge "${{ steps.cpr.outputs.pull-request-url }}"
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Approve update
|
|
if: ${{ steps.cpr.outputs.pull-request-number }}
|
|
run: |
|
|
review_status="$(
|
|
gh pr view "${{ steps.cpr.outputs.pull-request-url }}" \
|
|
--json="reviewDecision" \
|
|
--jq=".reviewDecision"
|
|
)"
|
|
echo "Pull request review status: ${review_status}"
|
|
if [[ "${review_status}" != "APPROVED" ]]; then
|
|
gh pr review --approve "${{ steps.cpr.outputs.pull-request-url }}"
|
|
fi
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.PHP_CURL_CLASS_TOKEN }}
|