Update #24645
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Update | |
on: | |
schedule: | |
- cron: '*/30 * * * *' | |
permissions: | |
contents: write | |
pull-requests: write | |
env: | |
IMAGE: "ghcr.io/${{ github.repository }}" | |
jobs: | |
update: | |
name: Update | |
runs-on: ubuntu-latest | |
environment: Update | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Update requirements | |
id: update | |
run: | | |
docker create --name=pip-compile \ | |
--entrypoint /bin/sh \ | |
--interactive \ | |
--user root \ | |
--workdir /tmp \ | |
$IMAGE | |
docker cp requirements.in pip-compile:/tmp/ | |
docker start --attach --interactive pip-compile < ci/pip-compile.sh | |
mv requirements.txt requirements.txt.orig | |
docker cp pip-compile:/tmp/requirements.txt . | |
docker rm -f pip-compile | |
if [ -n "$(git status --porcelain requirements.txt)" ]; then | |
docker create --name=generate-message \ | |
--entrypoint python \ | |
--interactive \ | |
--workdir /tmp \ | |
$IMAGE | |
docker cp requirements.txt.orig generate-message:/tmp/ | |
rm requirements.txt.orig | |
docker cp requirements.txt generate-message:/tmp/ | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
echo "commit-message<<$EOF" >> "$GITHUB_OUTPUT" | |
docker start --attach --interactive generate-message < ci/generate_message.py >> "$GITHUB_OUTPUT" | |
echo "$EOF" >> "$GITHUB_OUTPUT" | |
docker rm -f generate-message | |
fi | |
- name: Generate Token | |
id: generate-token | |
uses: tibdex/github-app-token@v2 | |
if: ${{ steps.update.outputs.commit-message }} | |
with: | |
app_id: ${{ secrets.APP_ID }} | |
private_key: ${{ secrets.APP_PRIVATE_KEY }} | |
- name: Create Pull Request | |
id: create-pull-request | |
uses: peter-evans/create-pull-request@v7 | |
if: ${{ steps.update.outputs.commit-message }} | |
with: | |
token: ${{ steps.generate-token.outputs.token }} | |
add-paths: | | |
requirements.txt | |
base: main | |
author: "update-pproxy[bot] <136385368+update-pproxy[bot]@users.noreply.github.com>" | |
committer: "update-pproxy[bot] <136385368+update-pproxy[bot]@users.noreply.github.com>" | |
branch: update/requirements | |
body: ${{ steps.update.outputs.commit-message}} | |
commit-message: | | |
chore(deps): Update Python Packages | |
${{ steps.update.outputs.commit-message }} | |
signoff: true | |
title: "chore(deps): Update Python Packages" | |
labels: | | |
dependencies | |
- name: Enable Auto-Merge | |
if: ${{ steps.create-pull-request.outputs.pull-request-number }} | |
env: | |
GH_TOKEN: ${{ steps.generate-token.outputs.token }} | |
run: | | |
gh pr merge --auto --squash "${{ steps.create-pull-request.outputs.pull-request-number }}" | |
- name: Generate Token (Approver) | |
id: generate-approver-token | |
uses: tibdex/github-app-token@v2 | |
if: ${{ steps.create-pull-request.outputs.pull-request-number }} | |
with: | |
app_id: ${{ secrets.APPROVER_APP_ID }} | |
private_key: ${{ secrets.APPROVER_APP_PRIVATE_KEY }} | |
- name: Approve Pull Request | |
if: ${{ steps.create-pull-request.outputs.pull-request-number }} | |
run: | | |
curl -L \ | |
-sS \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ steps.generate-approver-token.outputs.token }}"\ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/${{ github.repository }}/pulls/${{ steps.create-pull-request.outputs.pull-request-number }}/reviews \ | |
-d '{"commit_id":"${{ steps.create-pull-request.outputs.pull-request-head-sha }}","event":"APPROVE"}' |