From 17ac9f61787975dc81b0f2d6b6a06eca0156cca0 Mon Sep 17 00:00:00 2001 From: pixelass Date: Wed, 21 Feb 2024 15:35:02 +0100 Subject: [PATCH] chore: adjust workflow --- .github/workflows/set-pr-title.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/set-pr-title.yml b/.github/workflows/set-pr-title.yml index 2732135a0..6e9b5b05a 100644 --- a/.github/workflows/set-pr-title.yml +++ b/.github/workflows/set-pr-title.yml @@ -10,13 +10,20 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + with: + # Fetches the entire commit history so that we can access the first commit + fetch-depth: 0 - name: Get first commit message - run: echo "FIRST_COMMIT_MESSAGE=$(git log --format=%B -n 1 $(git rev-list --max-parents=0 HEAD))" >> $GITHUB_ENV + run: | + # Get the SHA of the first commit in the PR + FIRST_COMMIT_SHA=$(git log --reverse --format="%H" "${{ github.event.pull_request.base.sha }}..HEAD" | head -n 1) + # Get the message of the first commit in the PR + FIRST_COMMIT_MESSAGE=$(git log -n 1 --format=%B "$FIRST_COMMIT_SHA") + echo "FIRST_COMMIT_MESSAGE=$FIRST_COMMIT_MESSAGE" >> $GITHUB_ENV - name: Update PR title - run: | - gh pr edit "$PR_NUMBER" --title "$FIRST_COMMIT_MESSAGE" + run: gh pr edit "$PR_NUMBER" --title "$FIRST_COMMIT_MESSAGE" env: FIRST_COMMIT_MESSAGE: ${{ env.FIRST_COMMIT_MESSAGE }} GITHUB_TOKEN: ${{ secrets.PIXELASS_PAT_BLIBLA }}