From e528feb989d8fc7f7ca8c4100c0bf5ca7b912a5d Mon Sep 17 00:00:00 2001 From: Sergey Polzunov Date: Thu, 6 Feb 2025 19:39:49 +0100 Subject: [PATCH] chore(ci): new CI action trigger for REACT testing workflow (#4435) * React test trigger * Delete outdated CI trigger * Fixing a trigger event * Dummy rule updates * Fix workflow name * Fix typo in curl command * Use correct token * Using full workflow filename with extension * Simplified JSON in curl request * Using a correct value for branch * Use a correct ref for a workflow * Fix for invalid field name in a dispatch data * Simplify json body * Revert "Dummy rule updates" This reverts commit 6c18c5b8b39702cd4106c7b46b8534c76c4c9c27. --- .github/workflows/react-tests-dispatcher.yml | 23 +++++++++++++++++ .github/workflows/trigger-react.yml | 27 -------------------- 2 files changed, 23 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/react-tests-dispatcher.yml delete mode 100644 .github/workflows/trigger-react.yml diff --git a/.github/workflows/react-tests-dispatcher.yml b/.github/workflows/react-tests-dispatcher.yml new file mode 100644 index 000000000..e44cc4065 --- /dev/null +++ b/.github/workflows/react-tests-dispatcher.yml @@ -0,0 +1,23 @@ +name: REACT Tests Dispatcher + +on: + pull_request: + paths: + - 'rules/**/*.toml' + +jobs: + dispatch: + name: Run REACT tests + runs-on: ubuntu-latest + steps: + - name: Trigger REACT workflow + env: + REACT_WORKFLOW_ID: "detection-rules-tests.yml" + run: | + curl -X POST \ + -H "Accept: application/vnd.github.everest-preview+json" \ + -H "Content-Type: application/json" \ + -H "Authorization: token ${{ secrets.WRITE_DETECTION_RULES_REACT_TOKEN }}" \ + "https://api.github.com/repos/elastic/react/actions/workflows/$REACT_WORKFLOW_ID/dispatches" \ + -d '{"ref": "main", "inputs": {"pr_branch": "${{ github.head_ref || github.ref_name }}", "pr_id": "${{ github.event.number }}"}}' + exit $? diff --git a/.github/workflows/trigger-react.yml b/.github/workflows/trigger-react.yml deleted file mode 100644 index 29b4b7858..000000000 --- a/.github/workflows/trigger-react.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Trigger REACT Buildkite Pipeline - -on: - push: - branches: [ "main", "7.*", "8.*" ] - paths: - - 'rules/**/*.toml' - -jobs: - trigger_buildkite: - runs-on: ubuntu-latest - steps: - - name: Trigger a Buildkite REACT Build - run: | - curl -X POST "https://api.buildkite.com/v2/organizations/elastic/pipelines/react/builds" \ - -H "Authorization: Bearer ${{ secrets.REACT_BUILDKITE_API_TOKEN }}" \ - -H "Content-Type: application/json" \ - -d '{ - "commit": "HEAD", - "branch": "main", - "message": ":github: Triggered from a DR GitHub Action", - "env": { - "GITHUB_COMMIT_HASH": "${{ github.sha }}", - "GITHUB_HEAD_BRANCH": "${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }}", - "GITHUB_SRC_BRANCH": "${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || github.ref_name }}" - } - }'