From 371557237f485bd4c63a063d941b42c7a326420d Mon Sep 17 00:00:00 2001 From: David Holdeman Date: Tue, 21 Feb 2023 08:56:36 -0600 Subject: [PATCH] Build only one bundle (#5115) * check for only: * skip * comments --- .github/workflows/build-firmware.yaml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-firmware.yaml b/.github/workflows/build-firmware.yaml index ca0c9e92a8..fd42015089 100644 --- a/.github/workflows/build-firmware.yaml +++ b/.github/workflows/build-firmware.yaml @@ -296,10 +296,23 @@ jobs: - name: Check branch name if: ${{ contains(github.ref_name, '.') }} run: echo '::error::Branch names must not contain ".", this breaks firmware autoupdates.' && exit 1 + - name: Execution throttle early exit - # Don't skip any jobs if this workflow was run manually. - if: ${{ matrix.skip-rate && github.event_name != 'workflow_dispatch' }} - run: if (($(($RANDOM % 100)) < ${{ matrix.skip-rate }})); then echo "skip=true" >> $GITHUB_ENV; fi + # Don't skip any jobs if this workflow was run manually, + # or if the commit contains `only:`, signifying that only one bundle should be built. + if: ${{ matrix.skip-rate && github.event_name != 'workflow_dispatch' || contains(github.event.head_commit.message, 'only:') }} + run: | + # if the commit message contains `only:`, get the part after the semicolon and check if it matches the build target. + if echo ${{ github.event.head_commit.message }} | grep "only:"; then + if [ "$(echo ${{ github.event.head_commit.message }} | grep -Po '(?<=only:)[^\s]*')" = "${{ matrix.build-target }}" ]; then + exit 0 + else + # if it doesn't match, skip this job. + echo "skip=true" >> $GITHUB_ENV + exit 0 + fi + fi + if (($(($RANDOM % 100)) < ${{ matrix.skip-rate }})); then echo "skip=true" >> $GITHUB_ENV; fi - uses: actions/checkout@v3 if: ${{ env.skip != 'true' }}