Skip to content

Commit

Permalink
Merge pull request #1113 from wazuh/enhancement/5649-delete-tag-verify
Browse files Browse the repository at this point in the history
Modfy Puppet module builder
  • Loading branch information
teddytpc1 authored Sep 19, 2024
2 parents a3c0606 + ed1e8c8 commit b0fd0ce
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
54 changes: 28 additions & 26 deletions .github/workflows/Puppet_module_builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,40 @@ name: Puppet Module Builder
on:
workflow_dispatch:
inputs:
BRANCH_NAME:
type: string
description: "Branch or tag name"
required: true
default: "v4.10.0"
UPLOAD_S3:
upload:
description: "Upload ?"
type: boolean
default: false
is_stage:
description: "Is stage ?"
type: boolean
description: "Upload Puppet module to S3"
required: true
default: false
S3_REPOSITORY:
type: choice
description: "S3 Repository"
required: true
options:
- staging
- pre-release

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

env:
S3_PATH: "development/wazuh/4.x/secondary/puppet-module/"

jobs:
build_module:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.BRANCH_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-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_REPO=$(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"
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "PUPPET_MODULE_REPO=$PUPPET_MODULE_REPO" >> "$GITHUB_ENV"
echo "PUPPET_MODULE_VERSION=$PUPPET_MODULE_VERSION" >> "$GITHUB_ENV"
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
- name: Install dependencies
run: |
Expand All @@ -55,26 +47,36 @@ jobs:
sudo apt-get install pdk
pdk set config user.analytics.disabled false --type boolean --force
- name: Modify name for stage build
if: ${{ inputs.is_stage == false }}
run: |
pip install sde --break-system-packages
PUPPET_MODULE_VERSION="${PUPPET_MODULE_VERSION}-${{ env.COMMIT_SHORT_SHA}}"
sde version $PUPPET_MODULE_VERSION ${{ github.workspace }}/metadata.json
echo "PUPPET_MODULE_VERSION=$PUPPET_MODULE_VERSION" >> "$GITHUB_ENV"
- name: Build Wazuh Puppet module
run: |
mkdir -p ${{ github.workspace }}/output
pdk build --force --target-dir=${{ github.workspace }}/output/
PUPPET_MODULE_NAME=${{ env.PUPPET_MODULE_REPO }}-${{ env.PUPPET_MODULE_VERSION }}.tar.gz
echo "PUPPET_MODULE_NAME=$PUPPET_MODULE_NAME" >> "$GITHUB_ENV"
- name: Create Puppet module artifact
uses: actions/upload-artifact@v4
with:
name: Puppet module artifact
path: ${{ github.workspace }}/output/${{ env.PUPPET_MODULE_NAME }}-${{ env.PUPPET_MODULE_VERSION }}.tar.gz
path: ${{ github.workspace }}/output/${{ env.PUPPET_MODULE_NAME }}
retention-days: 1

- name: Configure aws credentials
if: ${{ env.WAZUH_TAG != '' && inputs.UPLOAD_S3 == true }}
uses: aws-actions/configure-aws-credentials@v3
if: ${{ inputs.upload == true }}
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_IAM_PUPPET_ROLE }}
aws-region: "${{ secrets.AWS_REGION }}"

- name: Upload Puppet module to S3
if: ${{ env.WAZUH_TAG != '' && inputs.UPLOAD_S3 == true }}
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/
if: ${{ inputs.upload == true }}
run: aws s3 cp ${{ github.workspace }}/output/${{ env.PUPPET_MODULE_NAME }} s3://${{ secrets.AWS_S3_BUCKET }}/${{ env.S3_PATH }}

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ kitchen/.librarian/
kitchen/.pytest_cache/
kitchen/.*
kitchen/modules/
output/
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ All notable changes to this project will be documented in this file.

### Changed

- None
- Modfy Puppet module builder ([#1113](https://github.com/wazuh/wazuh-puppet/pull/1113)) \- (Puppet Module Builder)

### Fixed

Expand Down
Empty file modified metadata.json
100644 → 100755
Empty file.

0 comments on commit b0fd0ce

Please sign in to comment.