diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d045b5d4fb103..f68708a1197fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,10 +10,14 @@ on: workflow_dispatch: inputs: revision: - description: "Any string or number used to extend the package's identifier" + description: "Revision" type: string required: true default: "1" + upload: + description: "Upload ?" + type: bool + default: false # ========================== # Bibliography @@ -74,3 +78,12 @@ jobs: uses: ./.github/workflows/r_test.yml with: package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}_${{ matrix.os.suffix }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.os.ext }} + + upload: + needs: [version, commit_sha, test] + # Upload only on 'workflow_dispatch' event and if 'upload=true' + if: ${{ github.event_name == 'push' && inputs.upload }} + uses: ./.github/workflows/r_upload.yml + with: + package: wazuh-indexer-${{ needs.version.outputs.version }}-${{ github.event_name == 'push' && '1' || inputs.revision }}_${{ matrix.os.suffix }}_${{ needs.commit_sha.outputs.commit_sha }}.${{ matrix.os.ext }} + secrets: inherit diff --git a/.github/workflows/r_upload.yml b/.github/workflows/r_upload.yml new file mode 100644 index 0000000000000..05a08e40394c4 --- /dev/null +++ b/.github/workflows/r_upload.yml @@ -0,0 +1,41 @@ +name: Upload (reusable) + +# This workflow runs when any of the following occur: +# - Run from another workflow +on: + workflow_call: + inputs: + package: + description: "The name of the package to upload to Wazuh's S3 development artifactory bucket." + required: true + type: string + secrets: + CI_INTERNAL_DEVELOPMENT_BUCKET_USER_ACCESS_KEY: + required: true + CI_INTERNAL_DEVELOPMENT_BUCKET_USER_SECRET_KEY: + required: true + +jobs: + r_upload: + runs-on: ubuntu-latest + # Permissions to upload the package + permissions: + packages: read + contents: read + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.package }} + path: artifacts/dist + + - name: Set up AWS CLI + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.CI_INTERNAL_DEVELOPMENT_BUCKET_USER_ACCESS_KEY }} + aws-secret-access-key: ${{ secrets.CI_INTERNAL_DEVELOPMENT_BUCKET_USER_SECRET_KEY }} + aws-region: us-east-1 + + - name: Upload package to S3 + run: | + aws s3 cp artifacts/dist/${{ inputs.package }} s3://packages-dev.internal.wazuh.com/development/wazuh/4.x/main/packages/