From b407e44e84e2cc4d749f6fb879da2fb54ab02edd Mon Sep 17 00:00:00 2001
From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com>
Date: Thu, 25 Aug 2022 10:42:09 +0100
Subject: [PATCH] [8.4](backport #32750) action: checks for winlogbeat and
 x-pack/winlogbeat (#32803)

---
 .github/workflows/check-winlogbeat.yml       | 27 ++++++++++++++++++++
 .github/workflows/check-xpack-winlogbeat.yml | 27 ++++++++++++++++++++
 .github/workflows/opentelemetry.yml          |  2 ++
 winlogbeat/Jenkinsfile.yml                   |  8 ------
 x-pack/winlogbeat/Jenkinsfile.yml            | 10 --------
 5 files changed, 56 insertions(+), 18 deletions(-)
 create mode 100644 .github/workflows/check-winlogbeat.yml
 create mode 100644 .github/workflows/check-xpack-winlogbeat.yml

diff --git a/.github/workflows/check-winlogbeat.yml b/.github/workflows/check-winlogbeat.yml
new file mode 100644
index 000000000000..41d7b95c0dd9
--- /dev/null
+++ b/.github/workflows/check-winlogbeat.yml
@@ -0,0 +1,27 @@
+name: check-winlogbeat
+
+on:
+  pull_request:
+    paths:
+      - '.github/workflows/check-winlogbeat.yml'
+      - 'winlogbeat/**'
+      - 'x-pack/winlogbeat/**'
+
+env:
+  BEAT_MODULE: 'winlogbeat'
+
+jobs:
+  check:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v3
+    - name: Fetch Go version from .go-version
+      run: echo "GO_VERSION=$(cat .go-version)" >> $GITHUB_ENV
+    - uses: actions/setup-go@v3
+      with:
+        go-version: ${{ env.GO_VERSION }}
+    - name: Run check/update
+      run: |
+        go install github.com/magefile/mage
+        make -C ${{ env.BEAT_MODULE }} check update
+        make check-no-changes
diff --git a/.github/workflows/check-xpack-winlogbeat.yml b/.github/workflows/check-xpack-winlogbeat.yml
new file mode 100644
index 000000000000..3a18353df6b5
--- /dev/null
+++ b/.github/workflows/check-xpack-winlogbeat.yml
@@ -0,0 +1,27 @@
+name: check-x-pack-winlogbeat
+
+on:
+  pull_request:
+    paths:
+      - '.github/workflows/check-xpack-winlogbeat.yml'
+      - 'x-pack/winlogbeat/**'
+      - 'winlogbeat/**'
+
+env:
+  BEAT_MODULE: 'x-pack/winlogbeat'
+
+jobs:
+  check:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v3
+    - name: Fetch Go version from .go-version
+      run: echo "GO_VERSION=$(cat .go-version)" >> $GITHUB_ENV
+    - uses: actions/setup-go@v3
+      with:
+        go-version: ${{ env.GO_VERSION }}
+    - name: Run check/update
+      uses: magefile/mage-action@v2
+      with:
+        args: check update
+        workdir: "${{ env.BEAT_MODULE }}"
diff --git a/.github/workflows/opentelemetry.yml b/.github/workflows/opentelemetry.yml
index 22e524da1dc3..e12caed0ceb5 100644
--- a/.github/workflows/opentelemetry.yml
+++ b/.github/workflows/opentelemetry.yml
@@ -6,10 +6,12 @@ on:
       - check-auditbeat
       - check-dev-tools
       - check-packetbeat
+      - check-winlogbeat
       - check-x-pack-auditbeat
       - check-x-pack-functionbeat
       - check-x-pack-osquerybeat
       - check-x-pack-packetbeat
+      - check-x-pack-winlogbeat
       - golangci-lint
       - auditbeat
       - filebeat
diff --git a/winlogbeat/Jenkinsfile.yml b/winlogbeat/Jenkinsfile.yml
index bdb09c73cb9d..339fdbc1a2cd 100644
--- a/winlogbeat/Jenkinsfile.yml
+++ b/winlogbeat/Jenkinsfile.yml
@@ -13,14 +13,6 @@ when:
     tags: true                 ## for all the tags
 platform: "immutable && ubuntu-18" ## default label for all the stages
 stages:
-    checks:
-        make: |
-          make -C winlogbeat check;
-          make -C winlogbeat update;
-          make -C x-pack/winlogbeat check;
-          make -C x-pack/winlogbeat update;
-          make check-no-changes;
-        stage: checks
     crosscompile:
         make: "make -C winlogbeat crosscompile"
         stage: mandatory
diff --git a/x-pack/winlogbeat/Jenkinsfile.yml b/x-pack/winlogbeat/Jenkinsfile.yml
index 9f3d7096682f..041dde58d205 100644
--- a/x-pack/winlogbeat/Jenkinsfile.yml
+++ b/x-pack/winlogbeat/Jenkinsfile.yml
@@ -13,16 +13,6 @@ when:
     tags: true                 ## for all the tags
 platform: "windows-2022"       ## default label for all the stages
 stages:
-    checks:
-        make: |
-          make -C x-pack/winlogbeat check;
-          make -C x-pack/winlogbeat update;
-          make -C winlogbeat check;
-          make -C winlogbeat update;
-          make check-no-changes;
-        platforms:             ## override default labels in this specific stage.
-            - "immutable && ubuntu-18"
-        stage: checks
     build:
         mage: "mage build unitTest"
         withModule: true