Skip to content

Commit

Permalink
Merge pull request #1109 from wazuh/enhancement/5649-puppet-module-bu…
Browse files Browse the repository at this point in the history
…ilder-module

Wazuh Puppet module builder
  • Loading branch information
teddytpc1 authored Sep 11, 2024
2 parents 71d796e + e32f364 commit bef6280
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions .github/workflows/Puppet_module_builder.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -35,17 +35,24 @@ jobs:
with:
ref: ${{ inputs.BRANCH_NAME }}

- name: Verify Tag name
- name: View parameters
run: echo "${{ toJson(inputs) }}"

- 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"
echo "PUPPET_MODULE_NAME=$PUPPET_MODULE_NAME" >> "$GITHUB_ENV"
echo "PUPPET_MODULE_VERSION=$PUPPET_MODULE_VERSION" >> "$GITHUB_ENV"
- 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
Expand All @@ -57,19 +64,17 @@ 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
if: ${{ env.WAZUH_TAG != '' && inputs.UPLOAD_S3 == true }}
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 }}
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/

0 comments on commit bef6280

Please sign in to comment.