From 95296003553ab7cf8bcd9eaacacb8ef8243145ec Mon Sep 17 00:00:00 2001 From: vcerenu Date: Wed, 11 Sep 2024 11:13:51 -0300 Subject: [PATCH 1/6] Add view parameter step and sudo commands --- .github/workflows/Puppet_module_builder.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Puppet_module_builder.yml b/.github/workflows/Puppet_module_builder.yml index c176b7b6..9f809125 100644 --- a/.github/workflows/Puppet_module_builder.yml +++ b/.github/workflows/Puppet_module_builder.yml @@ -35,6 +35,9 @@ jobs: with: ref: ${{ inputs.BRANCH_NAME }} + - name: View parameters + run: echo "${{ toJson(inputs) }}" + - name: Verify Tag name run: | WAZUH_TAG=$(curl --silent https://api.github.com/repos/wazuh/wazuh/git/refs/tags | grep '["]ref["]:' | sed -E 's/.*\"([^\"]+)\".*/\1/' | cut -c 11- | grep ^${{ inputs.BRANCH_NAME }}$) @@ -42,10 +45,10 @@ jobs: - name: Install dependencies run: | - curl -O https://apt.puppet.com/puppet-tools-release-noble.deb && \ - dpkg -i puppet-tools-release-noble.deb && \ - apt-get update && \ - apt-get install pdk + curl -O https://apt.puppet.com/puppet-tools-release-noble.deb + sudo dpkg -i puppet-tools-release-noble.deb + sudo apt-get update + sudo apt-get install pdk pdk set config user.analytics.disabled false --type boolean --force - name: Build Wazuh Puppet module From 1cc301c3d0a83ae61c93f39b6abdb38cac495670 Mon Sep 17 00:00:00 2001 From: vcerenu Date: Wed, 11 Sep 2024 11:27:39 -0300 Subject: [PATCH 2/6] Add parameters and module name --- .github/workflows/Puppet_module_builder.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Puppet_module_builder.yml b/.github/workflows/Puppet_module_builder.yml index 9f809125..8c11df7e 100644 --- a/.github/workflows/Puppet_module_builder.yml +++ b/.github/workflows/Puppet_module_builder.yml @@ -38,10 +38,14 @@ jobs: - name: View parameters run: echo "${{ toJson(inputs) }}" - - name: Verify Tag name + - name: Create environment variables for workflow run: | WAZUH_TAG=$(curl --silent https://api.github.com/repos/wazuh/wazuh/git/refs/tags | grep '["]ref["]:' | sed -E 's/.*\"([^\"]+)\".*/\1/' | cut -c 11- | grep ^${{ inputs.BRANCH_NAME }}$) + PUPPET_MODULE_NAME=$(jq .name ${{ github.workspace }}/metadata.json | sed -e 's|["'\'']||g') + PUPPET_MODULE_VERSOIN=$(jq .version ${{ github.workspace }}/metadata.json | sed -e 's|["'\'']||g') echo "WAZUH_TAG=$WAZUH_TAG" >> "$GITHUB_ENV" + echo "PUPPET_MODULE_NAME=$PUPPET_MODULE_NAME" >> "$GITHUB_ENV" + echo "PUPPET_MODULE_VERSOIN=$PUPPET_MODULE_VERSOIN" >> "$GITHUB_ENV" - name: Install dependencies run: | @@ -60,7 +64,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: Puppet module artifact - path: ${{ github.workspace }}/output/wazuh-wazuh-.tar.gz + path: ${{ github.workspace }}/output/${{ env.PUPPET_MODULE_NAME }}-${{ env.PUPPET_MODULE_VERSION }}.tar.gz retention-days: 1 - name: Configure aws credentials @@ -74,5 +78,5 @@ jobs: - name: Upload Puppet module to S3 if: ${{ env.WAZUH_TAG != '' && inputs.UPLOAD_S3 == true }} - run: aws s3 cp ${{ github.workspace }}/output/*.tar.gz s3://${{ secrets.AWS_S3_BUCKET }}/${{ inputs.S3_REPOSITORY }}/puppet-module/ + run: aws s3 cp ${{ github.workspace }}/output/${{ env.PUPPET_MODULE_NAME }}-${{ env.PUPPET_MODULE_VERSION }}.tar.gz s3://${{ secrets.AWS_S3_BUCKET }}/${{ inputs.S3_REPOSITORY }}/puppet-module/ From 3cbd7ccfcb87f9ad1c18ae07d3f42606e28fe1de Mon Sep 17 00:00:00 2001 From: vcerenu Date: Wed, 11 Sep 2024 11:30:58 -0300 Subject: [PATCH 3/6] Fix parameter name --- .github/workflows/Puppet_module_builder.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Puppet_module_builder.yml b/.github/workflows/Puppet_module_builder.yml index 8c11df7e..179d88cc 100644 --- a/.github/workflows/Puppet_module_builder.yml +++ b/.github/workflows/Puppet_module_builder.yml @@ -42,10 +42,10 @@ jobs: run: | WAZUH_TAG=$(curl --silent https://api.github.com/repos/wazuh/wazuh/git/refs/tags | grep '["]ref["]:' | sed -E 's/.*\"([^\"]+)\".*/\1/' | cut -c 11- | grep ^${{ inputs.BRANCH_NAME }}$) PUPPET_MODULE_NAME=$(jq .name ${{ github.workspace }}/metadata.json | sed -e 's|["'\'']||g') - PUPPET_MODULE_VERSOIN=$(jq .version ${{ github.workspace }}/metadata.json | sed -e 's|["'\'']||g') + PUPPET_MODULE_VERSION=$(jq .version ${{ github.workspace }}/metadata.json | sed -e 's|["'\'']||g') echo "WAZUH_TAG=$WAZUH_TAG" >> "$GITHUB_ENV" echo "PUPPET_MODULE_NAME=$PUPPET_MODULE_NAME" >> "$GITHUB_ENV" - echo "PUPPET_MODULE_VERSOIN=$PUPPET_MODULE_VERSOIN" >> "$GITHUB_ENV" + echo "PUPPET_MODULE_VERSION=$PUPPET_MODULE_VERSION" >> "$GITHUB_ENV" - name: Install dependencies run: | From 19b32e011f49e6a6c9f2d78f7b15b52d06915806 Mon Sep 17 00:00:00 2001 From: vcerenu Date: Wed, 11 Sep 2024 11:41:09 -0300 Subject: [PATCH 4/6] Fix parameter name --- .github/workflows/Puppet_module_builder.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/Puppet_module_builder.yml b/.github/workflows/Puppet_module_builder.yml index 179d88cc..44b9a4e5 100644 --- a/.github/workflows/Puppet_module_builder.yml +++ b/.github/workflows/Puppet_module_builder.yml @@ -72,9 +72,7 @@ jobs: uses: aws-actions/configure-aws-credentials@v3 with: role-to-assume: ${{ secrets.AWS_IAM_PUPPET_ROLE }} - role-session-name: "Puppet module-Builder" aws-region: "${{ secrets.AWS_REGION }}" - role-duration-seconds: 10800 - name: Upload Puppet module to S3 if: ${{ env.WAZUH_TAG != '' && inputs.UPLOAD_S3 == true }} From d4a726e4adbadeaee7dcde1267fd7273ff6b7920 Mon Sep 17 00:00:00 2001 From: vcerenu Date: Wed, 11 Sep 2024 12:49:18 -0300 Subject: [PATCH 5/6] Fix tag repository --- .github/workflows/Puppet_module_builder.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Puppet_module_builder.yml b/.github/workflows/Puppet_module_builder.yml index 44b9a4e5..7fd93904 100644 --- a/.github/workflows/Puppet_module_builder.yml +++ b/.github/workflows/Puppet_module_builder.yml @@ -40,7 +40,7 @@ jobs: - name: Create environment variables for workflow run: | - WAZUH_TAG=$(curl --silent https://api.github.com/repos/wazuh/wazuh/git/refs/tags | grep '["]ref["]:' | sed -E 's/.*\"([^\"]+)\".*/\1/' | cut -c 11- | grep ^${{ inputs.BRANCH_NAME }}$) + WAZUH_TAG=$(curl --silent https://api.github.com/repos/wazuh/wazuh-puppet/git/refs/tags | grep '["]ref["]:' | sed -E 's/.*\"([^\"]+)\".*/\1/' | cut -c 11- | grep ^${{ inputs.BRANCH_NAME }}$) PUPPET_MODULE_NAME=$(jq .name ${{ github.workspace }}/metadata.json | sed -e 's|["'\'']||g') PUPPET_MODULE_VERSION=$(jq .version ${{ github.workspace }}/metadata.json | sed -e 's|["'\'']||g') echo "WAZUH_TAG=$WAZUH_TAG" >> "$GITHUB_ENV" From e32f364eff4ec1d02c785530b6502a866f2cd639 Mon Sep 17 00:00:00 2001 From: vcerenu Date: Wed, 11 Sep 2024 13:01:57 -0300 Subject: [PATCH 6/6] Added the account name of the job executor --- .github/workflows/Puppet_module_builder.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Puppet_module_builder.yml b/.github/workflows/Puppet_module_builder.yml index 7fd93904..e0e4d891 100644 --- a/.github/workflows/Puppet_module_builder.yml +++ b/.github/workflows/Puppet_module_builder.yml @@ -1,4 +1,4 @@ -run-name: Build Wazuh Puppet module ${{ inputs.BRANCH_NAME }} +run-name: Build Wazuh Puppet module ${{ inputs.BRANCH_NAME }} - Launched by @${{ github.actor }} name: Puppet Module Builder on: