Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix init.d file installation for Alma Linux and Rocky Linux #2053

Merged
merged 183 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
183 commits
Select commit Hold shift + click to select a range
dd6ee39
Add Alma Linux, Rocky Linux and Oracle Linux to the init.d fix done f…
verdx Jan 19, 2023
1312148
Remove Oracle Linux as it does not replicate the error
verdx Jan 19, 2023
226f331
Fix Red Hat Enterprise Linux repeated and Alma Linux missing
verdx Jan 20, 2023
756ae34
Add Github Actions test for systemctl in RHEL 9 and derivatives
verdx Jan 20, 2023
1bd2583
Change names and Pull request paths
verdx Jan 20, 2023
de8edfc
Change images and fix script for github actions
verdx Jan 20, 2023
742b4a1
Small fix
verdx Jan 20, 2023
9ef7f71
Fix paths in workflows for github actions
verdx Jan 20, 2023
d947c57
Fix call to generate_rpm_package in github actions
verdx Jan 20, 2023
8d49c5a
Fix test path in shared file with docker
verdx Jan 20, 2023
83ee9ab
Merge branch 'master' into 1626-fix-rhel9-derived-services
verdx Jan 23, 2023
163d3b6
Fixes to github actions tests
verdx Jan 23, 2023
ef4db24
Add workflow to create rpm packages for all architectures
verdx Jan 24, 2023
752f5cc
Change working directory position on package creation workflow
verdx Jan 24, 2023
3861d8a
Unify install and enable tests
verdx Jan 24, 2023
c85eb2c
Remove working directory in package creation workflow
verdx Jan 24, 2023
26c962d
Fixes in install and enable test workflow
verdx Jan 24, 2023
1263c73
Remove `:` from docker images in install and enable test
verdx Jan 24, 2023
59c5a9c
Disable automatic cancel when one fails
verdx Jan 24, 2023
ca0619f
Install docker on rare architectures
verdx Jan 24, 2023
cec21cb
Fix variable
verdx Jan 24, 2023
a316ac2
The package is now downloaded as an artifact from the package creatio…
verdx Jan 24, 2023
0ad5cb2
The uploading of the package creation images is automatised in a GitH…
verdx Jan 24, 2023
4adee72
Fixes in upload images workflow
verdx Jan 25, 2023
34e79d2
Change file name for build packages workflow
verdx Jan 25, 2023
c42c420
More syntax fixes in upload images workflow
verdx Jan 25, 2023
fa93d78
Run upload images worflow when changed
verdx Jan 25, 2023
40c5e74
More syntax fixes for upload images workflow
verdx Jan 25, 2023
fc00106
Change path for dockerfile in upload image workflow
verdx Jan 25, 2023
6a2552b
Remove unnecessary slash in path for Dockerfile
verdx Jan 25, 2023
7d4e056
Add cancel of last runs for test install
verdx Jan 25, 2023
c046b70
Fix calls to env variable GITHUB_WORKSPACE
verdx Jan 25, 2023
5444938
Remove env variable from dockerfile path for upload package creation
verdx Jan 25, 2023
9d98190
Add build context to upload image workflow
verdx Jan 25, 2023
fe289e0
Change variable for the package name in the building of the package
verdx Jan 25, 2023
157cf2e
Change container name to include branch
verdx Jan 25, 2023
504586f
Change github branch name reference
verdx Jan 25, 2023
8603bde
Change the building and upload of images to be done with a script
verdx Jan 25, 2023
6eae325
Install docker on rare architecture containers to build image for pac…
verdx Jan 25, 2023
ad260a8
Copy build.sh to correct place before building images
verdx Jan 25, 2023
c459080
Separate commands
verdx Jan 25, 2023
f017bc8
Separate docker setup scripts for ubuntu and alpine
verdx Jan 25, 2023
8e4fdb2
Pass user as argument to the build and push image scritp
verdx Jan 25, 2023
dbf68f0
Remove unneccessary commands in alpine setup
verdx Jan 25, 2023
cccd73c
Allow for more than one command on the upload image workflow
verdx Jan 25, 2023
e77e3f7
Change OS on which the images are generated
verdx Jan 25, 2023
efd6472
Change Os in which the images are built
verdx Jan 25, 2023
72c1770
Merge branch 'master' into 1626-fix-rhel9-derived-services
verdx Jan 26, 2023
e6c763e
Correct name for images
verdx Jan 26, 2023
e79cd12
Add image name variable definition where needed
verdx Jan 26, 2023
f8d759d
Fix adding image_name to environment
verdx Jan 26, 2023
f10965d
Version is now in tag instead of name
verdx Jan 26, 2023
37be5b7
Add efficiency options to save images and
verdx Jan 26, 2023
c5cedae
Add environment variables to run-on-arch and setup docker on install …
verdx Jan 26, 2023
edb2d09
Remove GITHUB_WORKSPACE variable from explicitly declared variables f…
verdx Jan 26, 2023
a48f4ba
Echo the tag used to push the image to ghcr
verdx Jan 26, 2023
ede0cef
When the action is called from a PR, the image uploaded has the tag f…
verdx Jan 26, 2023
4132931
Download the docker images to create the packages
verdx Jan 26, 2023
b42cec3
Change OS for armv7 creation
verdx Jan 26, 2023
7ae6ded
Fix container name to pull from ghcr
verdx Jan 26, 2023
798beda
Unify build packages jobs
verdx Jan 26, 2023
e8962de
Unify upload images jobs
verdx Jan 26, 2023
47353e9
Fix variable names for the package building workflow
verdx Jan 26, 2023
2463c24
Fix variable name for container name in x86_64 and i386
verdx Jan 26, 2023
5b1fbee
Remove support for ppc64 aarch64 and armv7
verdx Jan 27, 2023
23a9b81
Fix syntax error in buil_rpm_packages.yml
verdx Jan 27, 2023
286d874
Remove unnecessary code
verdx Jan 27, 2023
040cb16
Force a run of the image upload workflow to create 4.5 images
verdx Jan 27, 2023
9f2ae9c
Fix tags
verdx Jan 27, 2023
018d1fc
Add deb GitHub Actions
verdx Jan 27, 2023
b80eb21
Merge branch 'master' into 1626-fix-rhel9-derived-services
verdx Jan 27, 2023
fbffbd2
Add `--force-yes` to apt-utils install in deb image build
verdx Jan 27, 2023
b68b669
Add `--force-yes` to the Dockerfile for deb package creation to be ab…
verdx Jan 27, 2023
a833e1f
Call package builder from image uploader if run from a pr
verdx Jan 27, 2023
5e5ed8f
Change call to package creations from step to job
verdx Jan 27, 2023
8b645f2
Dont build docker image when creating packages
verdx Jan 27, 2023
724c70e
Fix paths in trigger of worflows and call to TAG
verdx Jan 27, 2023
1138bff
Add clean workflow runs
verdx Jan 27, 2023
fbc3b19
Syntax errors
verdx Jan 27, 2023
a7b0e41
Add needs to sub-job in upload images and debug
verdx Jan 27, 2023
9c99ad5
Add argument --tag to generate_<system>_packages and call it on the a…
verdx Jan 27, 2023
903bb9a
Fix syntax
verdx Jan 27, 2023
c400874
Change made to force the different runtype of the workflow
verdx Jan 27, 2023
80451d0
Remove debug and fix call to pull image script
verdx Jan 27, 2023
e720ff7
Add other ways of triggering the cleaning
verdx Jan 27, 2023
26f4cb6
Debug
verdx Jan 27, 2023
4e768aa
Remove repo name from image name after pulling it
verdx Jan 27, 2023
fff3dd8
Upload the created package as an artifact
verdx Jan 27, 2023
7b707ce
Fix workflow names
verdx Jan 27, 2023
026d653
Remove the test for manager i386, as it is not supported
verdx Jan 30, 2023
16228ac
Add install and enable tests after the creation of packages
verdx Jan 30, 2023
5a9a743
Fix syntax error
verdx Jan 30, 2023
fb8b0eb
Change uses syntax from path to owner/repo/path
verdx Jan 30, 2023
2ad23d6
Add commit reference to uses
verdx Jan 30, 2023
8984233
Change variable used to add reference to commit
verdx Jan 30, 2023
0663e3d
Try direct path for reusable worflows
verdx Jan 30, 2023
d52d955
Change path type to reuse workflow
verdx Jan 30, 2023
35f1a02
Add call to test the packages after creating them
verdx Jan 30, 2023
ba1d831
Check if test install and enable works on its own
verdx Jan 30, 2023
68e3eee
Fixes
verdx Jan 30, 2023
023be39
Change call to VERSION variable inside step
verdx Jan 30, 2023
7abf95b
Fix variable VERSION setting
verdx Jan 30, 2023
dc2b1c7
Fix variable VERSION setting
verdx Jan 30, 2023
7da7999
Change single for double quotes when setting the package name
verdx Jan 30, 2023
aa2ebc3
Change path for the moving of the package and add argument to artifac…
verdx Jan 30, 2023
d1e6c05
Remove unneccessary working directory from step
verdx Jan 30, 2023
9462936
Cancel duplicate workflows and fix test install
verdx Jan 30, 2023
ec3f3d5
Call the install test after creating the packages
verdx Jan 30, 2023
253b2fe
Add tests install and enable for debian
verdx Jan 30, 2023
93afcdd
Change quotes in docker images name for testing
verdx Jan 30, 2023
43d7de2
Remove the skip duplicates action in the package building and change …
verdx Jan 30, 2023
42c6fef
Fix architecture errors for the install and enable tests
verdx Jan 30, 2023
32e2f1e
Fixes for the install and enable test for both rpm and deb
verdx Jan 30, 2023
080e1d9
Architecture fixes in install and enable test
verdx Jan 30, 2023
96a16e1
Change amazon linux from deb to rpm
verdx Jan 30, 2023
4a92498
Fixes
verdx Jan 30, 2023
887f670
Fixes
verdx Jan 30, 2023
50b5e27
Update apt repos before installing the package
verdx Jan 30, 2023
82c4953
Install systemd on DEB systems
verdx Jan 30, 2023
23ad407
DEB docker add architecture
verdx Jan 30, 2023
7ce0a3c
Remove distro combination ubuntu:jammy with i386 architecture
verdx Jan 30, 2023
527f94f
Change revision of packages for the name of the branch
verdx Jan 31, 2023
d35caa5
Change package revision name and add step to retry artifact uri
verdx Jan 31, 2023
642237f
Remove unnecessary input:
verdx Jan 31, 2023
18b4671
Remove hyphen for revision in rpm and debug
verdx Jan 31, 2023
051171d
Change the workflow conclusion neccessary to download the artifact to…
verdx Jan 31, 2023
0a42059
Change way to retry down,load of artifact
verdx Jan 31, 2023
f70e559
Increase timeout to download artifact
verdx Jan 31, 2023
9eb370b
Search for artifact with commit sha instead of workflow name
verdx Jan 31, 2023
58f5b3f
Search for artifacts with branch instead of commit
verdx Jan 31, 2023
03c9f25
Check artifact with workflow name
verdx Jan 31, 2023
e711c1b
Remove space in Clean runs workflow
verdx Jan 31, 2023
55978fa
Call to clean workflow runs
verdx Jan 31, 2023
a59e828
Remove pull_requests call to Clean runs workflow
verdx Jan 31, 2023
5773cfb
Check if artifact is available in the building package workflow
verdx Jan 31, 2023
6deda0c
Change action to download artifact
verdx Jan 31, 2023
02ca409
Go back to previous artifact download action
verdx Jan 31, 2023
c713ab2
Test downloading artifact from the building package workflow
verdx Jan 31, 2023
be6c7e4
Debug
verdx Jan 31, 2023
c19d381
Add waiting time after uploading artifact
verdx Jan 31, 2023
f64deed
Fix error
verdx Jan 31, 2023
0cac89f
Debugging
verdx Jan 31, 2023
c30f7f8
Yaml syntax fixes
verdx Jan 31, 2023
d03c3b5
Wait for the artifact to be uploaded if download fails
verdx Jan 31, 2023
07a3aed
Add continue_on_error to the install and enable test
verdx Jan 31, 2023
4abcd8b
Add continue-on-error to download of artifact
verdx Jan 31, 2023
b9538f1
Remove unnecessary always()
verdx Jan 31, 2023
7b1c9b6
Change day cleaning of workflow runs is done
verdx Jan 31, 2023
791cd81
Syntax fixes for the ghcr pushing and pulling scripts
verdx Feb 1, 2023
dbc7197
Add 4.5 to branches for which to create docker images on push
verdx Feb 1, 2023
36ffb4d
Fix cron attribute for Cleaning worfklow runs
verdx Feb 1, 2023
5045a01
Fix schedule cron for Clean runs
verdx Feb 1, 2023
ecbe45f
Difference between master and major versions when building packages
verdx Feb 1, 2023
37d496b
Cancel runs of the workflow for previous commits
verdx Feb 1, 2023
6cd6107
Set cancel to true when checking for previous runs
verdx Feb 1, 2023
e6ca436
Cancel previous runs for Build packages workflow
verdx Feb 1, 2023
13ba7e9
Step up waiting time for artifact download retry to 90 seconds
verdx Feb 1, 2023
733537b
Add workflow name and conclusion to retry of the artifact download
verdx Feb 1, 2023
bac6a0e
Fix to cancel previous runs step
verdx Feb 1, 2023
c5266ce
Remove retry of artifact download
verdx Feb 1, 2023
32e6a60
Try again the artifact download retry with 240 seconds
verdx Feb 1, 2023
a4f477e
Debug if the workspace is the same when reusing workflows
verdx Feb 1, 2023
ac63a74
Test calling builder from another workflow
verdx Feb 1, 2023
9fec45a
Remove check
verdx Feb 1, 2023
abcee78
Test as a different workflow and wait for the package to be created
verdx Feb 1, 2023
ed43bdc
Change interval and timeout to wait for package
verdx Feb 1, 2023
625c626
Add cancel last run to the tests
verdx Feb 1, 2023
e041a02
Add job to cancel and wait for the package to be built
verdx Feb 1, 2023
01389de
Test wait for one hour of package creation
verdx Feb 2, 2023
dc13d75
Try different action to wait
verdx Feb 2, 2023
00ad440
Fix version for new waiting action
verdx Feb 2, 2023
8c9d4ef
Fix download artifact from success workflow
verdx Feb 2, 2023
2bd2bc0
Change waiting action for deb too
verdx Feb 2, 2023
08bd107
Added CentOS 9 Stream and Fedora 34 to the orifinal fix
verdx Feb 2, 2023
f52d16b
Add install and enable test for fedora 34
verdx Feb 2, 2023
24734fb
Fix typo
verdx Feb 3, 2023
ad78e4b
Only create the correspondent docker image
verdx Feb 3, 2023
2ae6fd4
Add the changes to build_packages and fix in upload images
verdx Feb 3, 2023
5679018
Add changes to test install
verdx Feb 3, 2023
908ef35
Missing parenthesis
verdx Feb 3, 2023
39ea44e
Change how the conditionals are called in the test install files
verdx Feb 3, 2023
b51b449
Missing parenthesis
verdx Feb 3, 2023
c1fcff4
Merge remote-tracking branch 'origin/4.5' into 1626-fix-rhel9-derived…
verdx Feb 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/actions/ghcr-pull-and-push/build_and_push_image_to_ghcr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
GITHUB_PUSH_SECRET=$1
GITHUB_USER=$2
DOCKER_IMAGE_NAME=$3
BUILD_CONTEXT=$4
DOCKERFILE_PATH="$BUILD_CONTEXT/Dockerfile"
if [ -n "$5" ]; then
DOCKER_IMAGE_TAG=$5
else
DOCKER_IMAGE_TAG="latest"
fi
GITHUB_REPOSITORY="wazuh/wazuh-packages"
GITHUB_OWNER="wazuh"
IMAGE_ID=ghcr.io/${GITHUB_OWNER}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}
IMAGE_ID=$(echo ${IMAGE_ID} | tr '[A-Z]' '[a-z]')

# Login to GHCR
echo ${GITHUB_PUSH_SECRET} | docker login https://ghcr.io -u $GITHUB_USER --password-stdin

# Build image
echo build -t ${IMAGE_ID} -f ${DOCKERFILE_PATH} ${BUILD_CONTEXT}
docker build -t ${IMAGE_ID} -f ${DOCKERFILE_PATH} ${BUILD_CONTEXT}
docker push ${IMAGE_ID}
19 changes: 19 additions & 0 deletions .github/actions/ghcr-pull-and-push/pull_image_from_ghcr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
GITHUB_PUSH_SECRET=$1
GITHUB_USER=$2
DOCKER_IMAGE_NAME=$3
if [ -n "$4" ]; then
DOCKER_IMAGE_TAG="$4"
else
DOCKER_IMAGE_TAG="latest"
fi
GITHUB_REPOSITORY="wazuh/wazuh-packages"
GITHUB_OWNER="wazuh"
IMAGE_ID=ghcr.io/${GITHUB_OWNER}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}
IMAGE_ID=$(echo ${IMAGE_ID} | tr '[A-Z]' '[a-z]')

# Login to GHCR
echo ${GITHUB_PUSH_SECRET} | docker login https://ghcr.io -u $GITHUB_USER --password-stdin

# Pull and rename image
docker pull ${IMAGE_ID}
docker image tag ghcr.io/${GITHUB_OWNER}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}
31 changes: 31 additions & 0 deletions .github/actions/test-install-enable/install_and_enable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
echo "Installing Wazuh $2."

source /etc/os-release
if [ "$ID" = "centos" ] && [ "$VERSION_ID" = "8" ]; then
find /etc/yum.repos.d/ -type f -exec sed -i 's/mirrorlist/#mirrorlist/g' {} \;
find /etc/yum.repos.d/ -type f -exec sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' {} \;
fi

if [ -n "$(command -v yum)" ]; then
sys_type="yum"
elif [ -n "$(command -v apt-get)" ]; then
sys_type="apt-get"
apt-get update
apt-get install -y systemd
else
common_logger -e "Couldn't find type of system"
exit 1
fi

$sys_type install -y "/packages/$1"

echo "Enabling Wazuh $2."
systemctl enable wazuh-$2
if [ "$?" -eq 0 ]; then
echo "Wazuh $2 enabled - Test passed correctly."
exit 0
else
echo "Error: Wazuh $2 not enabled."
exit 1
fi
74 changes: 74 additions & 0 deletions .github/workflows/build-deb-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build Wazuh Packages - DEB - amd64 and i386
on:
pull_request:
paths:
- 'debs/SPECS/*'
- 'debs/generate_debian_package.sh'
workflow_dispatch:
workflow_call:

jobs:
Wazuh-agent-deb-package-build:
runs-on: ubuntu-latest
strategy:
matrix:
TYPE: [agent, manager]
ARCHITECTURE : [amd64, i386]
exclude:
- TYPE: manager
ARCHITECTURE: i386
fail-fast: false

steps:
- name: Cancel previous runs
uses: fkirc/skip-duplicate-actions@master
with:
cancel_others: 'true'
github_token: ${{ secrets.GITHUB_TOKEN }}
skip_after_successful_duplicate: 'false'

- uses: actions/checkout@v3

- name: Get changed files
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
deb_images:
- 'debs/Debian/**'
- 'debs/build.sh'
deb_images_i386:
- 'debs/Debian/i386/**'
- 'debs/build.sh'
deb_images_amd64:
- 'debs/Debian/amd64/**'
- 'debs/build.sh'
deb_packages:
- 'debs/SPECS/**'
- 'debs/generate_debian_package.sh'

- name: Set tag and container name
run: |
MAJOR=$(sed 's/\([0-9]*\.[0-9]*\)\.[0-9]*/\1/' $GITHUB_WORKSPACE/VERSION)
if [ "${{ steps.changes.outputs.deb_images }}" == "true" ]; then echo "TAG=${{ github.head_ref }}" >> $GITHUB_ENV; else echo "TAG=$MAJOR" >> $GITHUB_ENV ; fi
if [ $MAJOR == "4.6" ]; then echo "VERSION=master" >> $GITHUB_ENV $ ; else echo "VERSION=$MAJOR" >> $GITHUB_ENV; fi
echo "CONTAINER_NAME=deb_builder_${{ matrix.ARCHITECTURE }}" >> $GITHUB_ENV

- name: Download docker image for package building
run: |
bash $GITHUB_WORKSPACE/.github/actions/ghcr-pull-and-push/pull_image_from_ghcr.sh ${{ secrets.GITHUB_TOKEN }} ${{ github.actor}} $CONTAINER_NAME ${{ env.TAG }}

- name: Build the ${{ matrix.ARCHITECTURE }} deb Wazuh ${{ matrix.TYPE }} package
if: steps.changes.outputs.deb_packages == 'true' || (steps.changes.outputs.deb_images_i386 == 'true' && matrix.ARCHITECTURE == 'i386') || (steps.changes.outputs.deb_images_amd64 == 'true' && matrix.ARCHITECTURE == 'amd64')
working-directory: ./debs
run: |
REVISION="${{ github.head_ref }}"
bash generate_debian_package.sh -b ${{ env.VERSION }} -t ${{ matrix.TYPE }} -a ${{ matrix.ARCHITECTURE }} --dev -j 2 --dont-build-docker --tag ${{ env.TAG }} -r $REVISION
echo "PACKAGE_NAME=$(ls ./output | grep .deb | head -n 1)" >> $GITHUB_ENV

- name: Upload Wazuh ${{ matrix.TYPE }} ${{ matrix.ARCHITECTURE }} package as artifact
uses: actions/upload-artifact@v2
with:
name: ${{ env.PACKAGE_NAME }}
path: ${{github.workspace}}/debs/output/${{ env.PACKAGE_NAME }}
if-no-files-found: error
75 changes: 75 additions & 0 deletions .github/workflows/build-rpm-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Build Wazuh Packages - RPM - x86_64 and i386
on:
pull_request:
paths:
- 'rpms/SPECS/*'
- 'rpms/generate_rpm_package.sh'
workflow_dispatch:
workflow_call:


jobs:
Wazuh-agent-rpm-package-build:
runs-on: ubuntu-latest
strategy:
matrix:
TYPE: [agent, manager]
ARCHITECTURE : [x86_64, i386]
exclude:
- TYPE: manager
ARCHITECTURE: i386
fail-fast: false

steps:
- name: Cancel previous runs
uses: fkirc/skip-duplicate-actions@master
with:
cancel_others: 'true'
github_token: ${{ secrets.GITHUB_TOKEN }}
skip_after_successful_duplicate: 'false'

- uses: actions/checkout@v3

- name: Get changed files
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
rpm_images:
- 'rpms/CentOS/**'
- 'rpms/build.sh'
rpm_images_i386:
- 'rpms/CentOS/6/i386/**'
- 'rpms/build.sh'
rpm_images_x86_64:
- 'rpms/CentOS/6/x86_64/**'
- 'rpms/build.sh'
rpm_packages:
- 'rpms/SPECS/**'
- 'rpms/generate_rpm_package.sh'

- name: Set tag and container name
run: |
MAJOR=$(sed 's/\([0-9]*\.[0-9]*\)\.[0-9]*/\1/' $GITHUB_WORKSPACE/VERSION)
if [ "${{ steps.changes.outputs.rpm_images }}" == "true" ]; then echo "TAG=${{ github.head_ref }}" >> $GITHUB_ENV; else echo "TAG=$MAJOR" >> $GITHUB_ENV ; fi
if [ $MAJOR == "4.6" ]; then echo "VERSION=master" >> $GITHUB_ENV $ ; else echo "VERSION=$MAJOR" >> $GITHUB_ENV; fi
if [ "${{ matrix.ARCHITECTURE }}" == "x86_64" ]; then echo "CONTAINER_NAME=rpm_builder_x86" >> $GITHUB_ENV ; else echo "CONTAINER_NAME=rpm_builder_${{ matrix.ARCHITECTURE }}" >> $GITHUB_ENV ; fi

- name: Download docker image for package building
run: |
bash $GITHUB_WORKSPACE/.github/actions/ghcr-pull-and-push/pull_image_from_ghcr.sh ${{ secrets.GITHUB_TOKEN }} ${{ github.actor}} $CONTAINER_NAME ${{ env.TAG }}

- name: Build the ${{ matrix.ARCHITECTURE }} rpm Wazuh ${{ matrix.TYPE }} package
if : steps.changes.outputs.rpm_packages == 'true' || (steps.changes.outputs.rpm_images_i386 == 'true' && matrix.ARCHITECTURE == 'i386') || (steps.changes.outputs.rpm_images_x86_64 == 'true' && matrix.ARCHITECTURE == 'x86_64')
working-directory: ./rpms
run: |
REVISION=$( echo ${{ github.head_ref }} | sed 's/-/./g' )
bash generate_rpm_package.sh -b ${{ env.VERSION }} -t ${{ matrix.TYPE }} -a ${{ matrix.ARCHITECTURE }} --dev -j 2 --dont-build-docker --tag ${{ env.TAG }} -r $REVISION
echo "PACKAGE_NAME=$(ls ./output | grep .rpm | head -n 1)" >> $GITHUB_ENV

- name: Upload Wazuh ${{ matrix.TYPE }} ${{ matrix.ARCHITECTURE }} package as artifact
uses: actions/upload-artifact@v2
with:
name: ${{ env.PACKAGE_NAME }}
path: ${{github.workspace}}/rpms/output/${{ env.PACKAGE_NAME }}
if-no-files-found: error
19 changes: 19 additions & 0 deletions .github/workflows/clean-worflow-runs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Clean workflow runs
on:
schedule:
- cron: '0 0 * * 5'
workflow_dispatch:

jobs:
Clean-runs:
runs-on: ubuntu-latest
steps:
- name: Delete workflow runs
uses: dmvict/clean-workflow-runs@v1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
run_conclusions: |
cancelled
skipped
timed_out
save_period: 5
94 changes: 94 additions & 0 deletions .github/workflows/test-install-and-enable-deb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Test install and enable Wazuh agent and manager - DEB
on:
pull_request:
paths:
- 'debs/SPECS/*'
- 'debs/generate_debian_package.sh'
workflow_dispatch:
workflow_call:

jobs:

Wait-for-package-building:
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Cancel previous runs
uses: fkirc/skip-duplicate-actions@master
with:
cancel_others: 'true'
github_token: ${{ secrets.GITHUB_TOKEN }}
skip_after_successful_duplicate: 'false'

- name: Wait for the package to be built
uses: ArcticLampyrid/action-wait-for-workflow@v1.0.3
id: wait-for-build
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-deb-packages.yml
sha: ${{ github.event.pull_request.head.sha || github.sha }}
wait-interval: 60

Test-install-and-enable-deb-systems:
needs: Wait-for-package-building
runs-on: ubuntu-latest
strategy:
matrix:
distro_name: ['ubuntu:xenial', 'ubuntu:bionic', 'ubuntu:focal', 'ubuntu:jammy', 'debian:stretch', 'debian:buster', 'debian:bullseye']
type: [agent, manager]
arch: [amd64, i386]
exclude:
- type: manager
arch: i386
- distro_name: 'ubuntu:jammy'
arch: i386
fail-fast: false
steps:
- uses: actions/checkout@v3

- name: Get changed files
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
deb_images:
- 'debs/Debian/**'
- 'debs/build.sh'
deb_images_i386:
- 'debs/Debian/i386/**'
- 'debs/build.sh'
deb_images_amd64:
- 'debs/Debian/amd64/**'
- 'debs/build.sh'
deb_packages:
- 'debs/SPECS/**'
- 'debs/generate_debian_package.sh'

- name: Setup directories and variables
if: steps.changes.outputs.deb_packages == 'true' || (steps.changes.outputs.deb_images_i386 == 'true' && matrix.ARCHITECTURE == 'i386') || (steps.changes.outputs.deb_images_amd64 == 'true' && matrix.ARCHITECTURE == 'amd64')
run: |
VERSION=$(cat $GITHUB_WORKSPACE/VERSION)
REVISION=$( echo ${{ github.head_ref }})
echo "PACKAGE_NAME=wazuh-${{ matrix.type }}_${VERSION}-${REVISION}_${{ matrix.arch }}.deb" >> $GITHUB_ENV

- name: Download the Wazuh ${{ matrix.type }} package for ${{ matrix.system.NAME }}
if: steps.changes.outputs.deb_packages == 'true' || (steps.changes.outputs.deb_images_i386 == 'true' && matrix.ARCHITECTURE == 'i386') || (steps.changes.outputs.deb_images_amd64 == 'true' && matrix.ARCHITECTURE == 'amd64')
id: download-artifact
continue-on-error: true
uses: dawidd6/action-download-artifact@v2
with:
workflow: build-deb-packages.yml
workflow_conclusion: success
name: ${{env.PACKAGE_NAME}}
if_no_artifact_found: fail

- name: Move the Wazuh ${{ matrix.type }} package for ${{ matrix.distro_name }} to the packages directory
if: steps.changes.outputs.deb_packages == 'true' || (steps.changes.outputs.deb_images_i386 == 'true' && matrix.ARCHITECTURE == 'i386') || (steps.changes.outputs.deb_images_amd64 == 'true' && matrix.ARCHITECTURE == 'amd64')
run: |
mkdir $GITHUB_WORKSPACE/packages
mv ${{env.PACKAGE_NAME}} $GITHUB_WORKSPACE/packages

- name: Launch docker
if: steps.changes.outputs.deb_packages == 'true' || (steps.changes.outputs.deb_images_i386 == 'true' && matrix.ARCHITECTURE == 'i386') || (steps.changes.outputs.deb_images_amd64 == 'true' && matrix.ARCHITECTURE == 'amd64')
run: sudo docker run -v $GITHUB_WORKSPACE/.github/actions/test-install-enable/:/tests -v $GITHUB_WORKSPACE/packages/:/packages ${{ matrix.arch }}/${{ matrix.distro_name }} bash /tests/install_and_enable.sh $PACKAGE_NAME ${{ matrix.type }}
Loading