From b8f747b8a12d7cddb39c88d7b9c93dc74d8b7ed7 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Mon, 19 Feb 2024 11:50:44 +0100 Subject: [PATCH] Improved commit message for firmware build --- .github/workflows/validate_esphome.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/validate_esphome.yml b/.github/workflows/validate_esphome.yml index cdeffe4..a69a6a2 100644 --- a/.github/workflows/validate_esphome.yml +++ b/.github/workflows/validate_esphome.yml @@ -201,13 +201,24 @@ jobs: cp prebuilt/.esphome/build/nspanel/.pioenvs/nspanel/firmware.bin prebuilt/nspanel_esphome_prebuilt.bin || true cp prebuilt/.esphome/build/nspanel/.pioenvs/nspanel/firmware-factory.bin prebuilt/nspanel_esphome_prebuilt-factory.bin || true - - name: Commit and Push Firmware File + - name: Set Commit Message + id: set_commit_message + run: | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + echo "COMMIT_MESSAGE=Pre-built firmware for NSPanel - ${{ github.event.pull_request.title }}" >> $GITHUB_ENV + elif [[ "${{ github.event_name }}" == "push" ]]; then + commit_message=$(git log -1 --pretty=format:'%s') + echo "COMMIT_MESSAGE=Pre-built firmware for NSPanel - $commit_message" >> $GITHUB_ENV + else + echo "COMMIT_MESSAGE=Pre-built firmware for NSPanel" >> $GITHUB_ENV + fi + + - name: Commit and Push Firmware Files run: | git config --global user.name 'GitHub Actions' git config --global user.email 'actions@github.com' - commit_message="${{ github.event.pull_request.title || 'Actions' }}" git add prebuilt/*.bin - git commit -m "Pre-built firmware for NSPanel - $commit_message" + git commit -m "${{ env.COMMIT_MESSAGE }}" git push env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}