From 1c90c131b77ffd4208acd8abc3a60399c0253cc8 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Fri, 24 Jan 2025 14:06:03 +0100 Subject: [PATCH] fix reapproval --- .github/workflows/auto-update-app-headers.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/auto-update-app-headers.yml b/.github/workflows/auto-update-app-headers.yml index 15f7ee04..f1303ebd 100644 --- a/.github/workflows/auto-update-app-headers.yml +++ b/.github/workflows/auto-update-app-headers.yml @@ -70,9 +70,20 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + # Get the PR number for the current branch PR_NUMBER=$(gh pr list --head "pr-update-app-files" --json number --jq '.[].number') - PR_AUTHOR=$(gh pr view "$PR_NUMBER" --json author --jq '.author.login') - if [ "$PR_AUTHOR" != "github-actions[bot]" ]; then - gh pr review "$PR_NUMBER" --approve + + # Check if a PR number was retrieved + if [ -n "$PR_NUMBER" ]; then + # Get the PR author + PR_AUTHOR=$(gh pr view "$PR_NUMBER" --json author --jq '.author.login') + + # Approve the PR if it was not created by the bot + if [ "$PR_AUTHOR" != "github-actions[bot]" ]; then + gh pr review "$PR_NUMBER" --approve + else + echo "PR was created by the bot, skipping review." + fi else - echo "PR was created by the bot, skipping review." + echo "No PR found for the current branch." + fi