From bcc424ee89234e963725a80fa22c6d1aebd550c8 Mon Sep 17 00:00:00 2001 From: itsankit-google Date: Mon, 9 Dec 2024 18:50:14 +0000 Subject: [PATCH] fix github action to run on labeled event --- .github/workflows/build.yml | 20 ++++++++++++---- .github/workflows/trigger.yml | 45 ----------------------------------- 2 files changed, 15 insertions(+), 50 deletions(-) delete mode 100644 .github/workflows/trigger.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bf50ee78ffb..68502b34bce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ on: branches: [ develop, release/** ] pull_request: branches: [ develop, release/** ] - types: [opened, synchronize, reopened] + types: [opened, synchronize, reopened, labeled] workflow_dispatch: inputs: branch: @@ -32,11 +32,21 @@ jobs: runs-on: k8s-runner-e2e - if: ${{ github.event.workflow_run.conclusion != 'skipped' }} + # We allow builds: + # 1) When it's a merge into a branch + # 2) For PRs that are labeled as build and + # - It's a code change + # - A build label was just added + # A bit complex, but prevents builds when other labels are manipulated + if: > + github.event_name == 'push' + || (contains(github.event.pull_request.labels.*.name, 'build') + && (github.event.action != 'labeled' || github.event.label.name == 'build') + ) steps: # Pinned 1.0.0 version - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive @@ -46,7 +56,7 @@ jobs: with: node-version: 22.12 - - uses: actions/cache@v3.3.0 + - uses: actions/cache@v4 with: path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} @@ -99,7 +109,7 @@ jobs: mvn clean verify -P e2e-tests -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn - name: Archive build artifacts - uses: actions/upload-artifact@v3.1.2 + uses: actions/upload-artifact@v4 if: always() with: name: Build debug files diff --git a/.github/workflows/trigger.yml b/.github/workflows/trigger.yml deleted file mode 100644 index 45a049a04fc..00000000000 --- a/.github/workflows/trigger.yml +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright © 2022 Cask Data, Inc. -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -# This workflow will trigger build.yml only when needed. -# This way we don't flood main workflow run list -# Note that node.js.yml from develop will be used even for PR builds -# Also it will have access to the proper secrets - -name: Trigger build - -on: - push: - branches: [ develop, release/**, feature/wrangler-2022 ] - pull_request: - branches: [ develop, release/**, feature/wrangler-2022 ] - types: [opened, synchronize, reopened, labeled] - workflow_dispatch: - -jobs: - trigger: - runs-on: ubuntu-latest - - # We allow builds: - # 1) When triggered manually - # 2) When it's a merge into a branch - # 3) For PRs that are labeled as build and - # - It's a code change - # - A build label was just added - # A bit complex, but prevents builds when other labels are manipulated - if: > - github.event_name == 'workflow_dispatch' - || github.event_name == 'push' - || github.event_name == 'pull_request' - - steps: - - name: Trigger build - run: echo UI build will be triggered now