From b2a5c1870bac94404c91ce30b9dd024d8796f51c Mon Sep 17 00:00:00 2001 From: MonsterDruide1 <5958456@gmail.com> Date: Tue, 27 Feb 2024 22:53:35 +0100 Subject: [PATCH] Fix author information on PR branch of OdysseyHeaders --- .github/scripts/push-headers.sh | 6 +++--- .github/workflows/copy-headers.yml | 29 ++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.github/scripts/push-headers.sh b/.github/scripts/push-headers.sh index bdeba31..9447b67 100644 --- a/.github/scripts/push-headers.sh +++ b/.github/scripts/push-headers.sh @@ -12,9 +12,9 @@ cd "./OdysseyHeaders" echo "Open root of OdysseyHeaders repo" git add -A . -git config user.name $COMMIT_AUTHOR_NAME -git config user.email $COMMIT_AUTHOR_MAIL -git commit -am "$COMMIT_MESSAGE" +git config user.name $AUTHOR_NAME +git config user.email $AUTHOR_MAIL +git commit -am "$MESSAGE" git push -f -u origin $HEADER_BRANCH echo "Updated headers successfully pushed to OdysseyHeaders repo" diff --git a/.github/workflows/copy-headers.yml b/.github/workflows/copy-headers.yml index 8e34b21..d87ac29 100644 --- a/.github/workflows/copy-headers.yml +++ b/.github/workflows/copy-headers.yml @@ -35,12 +35,35 @@ jobs: if [[ $GITHUB_EVENT_NAME == 'pull_request_target' ]] then echo "HEADER_BRANCH=pr-$PR_NUM" >> "$GITHUB_ENV" + if [[ $PR_AUTHOR_NAME != '' ]] + then + echo "AUTHOR_NAME=$PR_AUTHOR_NAME" >> "$GITHUB_ENV" + else + echo "AUTHOR_NAME=$PR_AUTHOR_LOGIN" >> "$GITHUB_ENV" + fi + if [[ $PR_AUTHOR_MAIL != '' ]] + then + echo "AUTHOR_MAIL=$PR_AUTHOR_MAIL" + else + echo "AUTHOR_MAIL=$PR_AUTHOR_LOGIN@noreply.github.com" >> "$GITHUB_ENV" + fi + echo "MESSAGE=$PR_TITLE" else echo "HEADER_BRANCH=$DELETED_BRANCH" >> "$GITHUB_ENV" + echo "AUTHOR_NAME=$COMMIT_AUTHOR_NAME" >> "$GITHUB_ENV" + echo "AUTHOR_MAIL=$COMMIT_AUTHOR_MAIL" >> "$GITHUB_ENV" + echo "MESSAGE=$COMMIT_MESSAGE" >> "$GITHUB_ENV" fi env: DELETED_BRANCH: ${{ github.event.ref }} - PR_NUM: ${{ github.event.number }} + PR_NUM: ${{ github.event.pull_request.number }} + COMMIT_AUTHOR_NAME: ${{ github.event.commits[0].author.name }} + COMMIT_AUTHOR_MAIL: ${{ github.event.commits[0].author.email }} + COMMIT_MESSAGE: ${{ github.event.commits[0].message }} + PR_AUTHOR_NAME: ${{ github.event.pull_request.user.name }} + PR_AUTHOR_LOGIN: ${{ github.event.pull_request.user.login }} + PR_AUTHOR_MAIL: ${{ github.event.pull_request.user.email }} + PR_TITLE: ${{ github.event.pull_request.title }} - name: Move to correct branch of OdysseyHeaders and reset history run: | cd OdysseyHeaders @@ -52,7 +75,3 @@ jobs: DESTINATION_PATH: ./OdysseyHeaders - name: Push to OdysseyHeaders repo run: bash ./.github/scripts/push-headers.sh - env: - COMMIT_AUTHOR_NAME: ${{ github.event.commits[0].author.name }} - COMMIT_AUTHOR_MAIL: ${{ github.event.commits[0].author.email }} - COMMIT_MESSAGE: ${{ github.event.commits[0].message }}