From 4a3d4a055de5e024c119ffce20f11fa675eaaeac Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Fri, 10 Jan 2025 12:17:44 +0100 Subject: [PATCH] Update generate-app-headers.yaml --- .github/workflows/generate-app-headers.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/generate-app-headers.yaml b/.github/workflows/generate-app-headers.yaml index 19e261e6..2e5662ad 100644 --- a/.github/workflows/generate-app-headers.yaml +++ b/.github/workflows/generate-app-headers.yaml @@ -34,7 +34,7 @@ jobs: - name: Create or update branch run: | - # Check if the branch exists + # Check if the branch exists, and create it if not git fetch origin git checkout -b update-app-headers || git checkout update-app-headers @@ -42,10 +42,10 @@ jobs: git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" - # Check if there are changes to commit + # Make sure there are changes to commit git diff --quiet || git commit -am "[core]: update .app-headers to latest version" - # Push changes to the branch only if there are changes + # Push changes to the branch if there are any git push origin update-app-headers --force || echo "No changes to push" - name: Create pull request @@ -55,6 +55,7 @@ jobs: run: | PR_EXISTS=$(gh pr list --head "update-app-headers" --json number --jq '.[].number') if [ -z "$PR_EXISTS" ]; then + # Create the pull request if it doesn't exist gh pr create --title "[core]: update .app-headers to latest version" \ --body "This PR automatically updates the app-headers file." \ --head update-app-headers \ @@ -66,7 +67,9 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + # Get the PR number and merge it if it exists PR_NUMBER=$(gh pr list --head "update-app-headers" --json number --jq '.[].number') if [ -n "$PR_NUMBER" ]; then + # Squash and merge the PR automatically gh pr merge $PR_NUMBER --squash --auto --delete-branch fi