From 45df1331288ff8a96ab6c4afc039b3d4b0866865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Sch=C3=BCnemann?= Date: Wed, 11 Jun 2025 16:18:36 +0200 Subject: [PATCH] when in a PR and created by PR attempt to add generated files --- .github/workflows/ci.lib.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/ci.lib.yaml b/.github/workflows/ci.lib.yaml index 9856a86..a050ce1 100644 --- a/.github/workflows/ci.lib.yaml +++ b/.github/workflows/ci.lib.yaml @@ -26,6 +26,28 @@ jobs: - name: task generate run: | task generate --verbose + + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + PR_USER=$(jq -r .pull_request.user.login "$GITHUB_EVENT_PATH") + if [ "$PR_USER" = "renovate[bot]" ]; then + echo "attempting to commit generated files" + + AUTHOR_NAME=$(git log -1 --pretty=format:'%an') + AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae') + echo "Committing as $AUTHOR_NAME <$AUTHOR_EMAIL>" + + echo "AUTHOR_NAME=$AUTHOR_NAME" >> $GITHUB_ENV + echo "AUTHOR_EMAIL=$AUTHOR_EMAIL" >> $GITHUB_ENV + + git config user.name "$AUTHOR_NAME" + git config user.email "$AUTHOR_EMAIL" + + git add -A + git commit -m "chore: regenerate files" || echo "No changes to commit" + git push origin "${{ github.head_ref }}" || echo "No changes to push" + fi + fi + git diff --exit-code - name: task validate