From 0cef15014744a944e1b5c9344f4b857107fa802d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Sat, 30 Dec 2023 10:38:15 +0100 Subject: [PATCH] Fix record screenshots workflow and script --- .github/workflows/recordScreenshots.yml | 5 ++--- .../workflows/scripts/recordScreenshots.sh | 22 ++++++++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/recordScreenshots.yml b/.github/workflows/recordScreenshots.yml index ea86142700..8658fa2de7 100644 --- a/.github/workflows/recordScreenshots.yml +++ b/.github/workflows/recordScreenshots.yml @@ -26,7 +26,7 @@ jobs: uses: nschloe/action-cached-lfs-checkout@v1.2.2 with: persist-credentials: false - ref: ${{ github.event.pull_request.head.ref }} + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }} - name: ⏬ Checkout with LFS (Branch) if: github.event_name == 'workflow_dispatch' uses: nschloe/action-cached-lfs-checkout@v1.2.2 @@ -45,6 +45,5 @@ jobs: - name: Record screenshots run: ./.github/workflows/scripts/recordScreenshots.sh env: - GITHUB_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }} - diff --git a/.github/workflows/scripts/recordScreenshots.sh b/.github/workflows/scripts/recordScreenshots.sh index 5a86a91580..ad3e372970 100755 --- a/.github/workflows/scripts/recordScreenshots.sh +++ b/.github/workflows/scripts/recordScreenshots.sh @@ -68,11 +68,27 @@ echo "Record screenshots" ./gradlew recordPaparazziDebug --stacktrace -PpreDexEnable=false --max-workers 4 --warn echo "Committing changes" -git config user.name "ElementBot" -git config user.email "benoitm+elementbot@element.io" +git config http.sslVerify false + +if [[ -z ${INPUT_AUTHOR_NAME} ]]; then + git config user.name "ElementBot" +else + git config --local user.name "${INPUT_AUTHOR_NAME}" +fi + +if [[ -z ${INPUT_AUTHOR_EMAIL} ]]; then + git config user.email "benoitm+elementbot@element.io" +else + git config --local user.name "${INPUT_AUTHOR_EMAIL}" +fi git add -A git commit -m "Update screenshots" +GITHUB_REPO="https://$GITHUB_ACTOR:$TOKEN@github.com/$REPO.git" echo "Pushing changes" -git push "https://$TOKEN@github.com/$REPO.git" $BRANCH +if [[ -z ${GITHUB_ACTOR} ]]; then + echo "No GITHUB_ACTOR env var" + GITHUB_REPO="https://$TOKEN@github.com/$REPO.git" +fi +git push $GITHUB_REPO "$BRANCH" echo "Done!"