From 441f6118022c14f65e2a751d8eef225d91452c21 Mon Sep 17 00:00:00 2001 From: Grigory Entin Date: Tue, 27 Jun 2023 00:48:11 +0200 Subject: [PATCH] Switched to body-based trigger. --- .github/workflows/main.yml | 44 +++++++++++++++++++++++++++++++++----- ReusableWorkflows | 2 +- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 56916183..db361007 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,17 +17,51 @@ on: push: branches: [main] pull_request: - types: [opened, synchronize, reopened, ready_for_review] + types: [opened, synchronize, reopened, ready_for_review, edited] +defaults: + run: + shell: bash --noprofile --norc -x -euo pipefail {0} + jobs: paths-filter: name: 'Paths Filter' uses: ./.github/workflows/paths-filter.yml + trigger-filter: + name: 'Trigger' + runs-on: ubuntu-latest + outputs: + should-test: ${{ steps.filter.outputs.should-test }} + should-build: ${{ steps.filter.outputs.should-build }} + + steps: + - name: 'Filter comments' + if: ${{ github.event_name == 'pull_request' && github.event.action == 'edited' }} + id: filter + run: | + echo "should-test=false" >> $GITHUB_OUTPUT + echo "should-build=false" >> $GITHUB_OUTPUT + body=$(curl https://api.github.com/repos/grigorye/TMBuddy/pulls/112 | jq -r '.body') + jq . "$GITHUB_EVENT_PATH" + if ! [[ "$body" =~ '- [x] *Run* checks:' ]]; then + exit 0 + fi + if [[ "$body" =~ '- [x] all' ]]; then + echo "should-test=true" >> $GITHUB_OUTPUT + echo "should-build=true" >> $GITHUB_OUTPUT + fi + if [[ "$body" =~ '- [x] tests' ]]; then + echo "should-test=true" >> $GITHUB_OUTPUT + fi + if [[ "$body" =~ '- [x] build app' ]]; then + echo "should-build=true" >> $GITHUB_OUTPUT + fi + tests: name: 'Tests' - needs: [paths-filter] - if: ${{ !inputs.skip-tests && github.event.pull_request.draft != true && needs.paths-filter.outputs.should-test != 'false' }} + needs: [paths-filter, trigger-filter] + if: ${{ !inputs.skip-tests && github.event.pull_request.draft != true && needs.paths-filter.outputs.should-test != 'false' && needs.trigger-filter.outputs.should-test == 'true' }} uses: grigorye/ReusableWorkflows/.github/workflows/tests-generic.yml@v20 secrets: inherit with: @@ -38,8 +72,8 @@ jobs: build-app: name: 'App' - needs: [paths-filter] - if: ${{ !inputs.skip-build-app && github.event.pull_request.draft != true && needs.paths-filter.outputs.should-build != 'false' }} + needs: [paths-filter, trigger-filter] + if: ${{ !inputs.skip-build-app && github.event.pull_request.draft != true && needs.paths-filter.outputs.should-build != 'false' && needs.trigger-filter.outputs.should-build == 'true' }} uses: grigorye/ReusableWorkflows/.github/workflows/build-app-generic.yml@v20 with: macos-app-scheme: 'TMBuddy' diff --git a/ReusableWorkflows b/ReusableWorkflows index 108edff1..b87d51f2 160000 --- a/ReusableWorkflows +++ b/ReusableWorkflows @@ -1 +1 @@ -Subproject commit 108edff102616bde2f6809c07a145db5764eb74a +Subproject commit b87d51f21c1584185fa42f1535808c198ae3fa35