Skip to content

Commit

Permalink
Upload packages to S3 (#179)
Browse files Browse the repository at this point in the history
* Attemtp to automate package's testing

* Add workflow file to upload packages to S3

* Skip testing to test whether the upload works

* Fix package names

* Fix upload workflow name

* Pass secrets to the reusable workflow

* Fix indentation

* Fix indentation

* Remove test workflow from this PR

* Add boolean input to control when the package is uploaded to the S3 bucket

* [UI/UX] Improve inputs description

---------

Signed-off-by: Álex Ruiz <[email protected]>
  • Loading branch information
AlexRuiz7 authored Mar 8, 2024
1 parent ad95578 commit 9cbf922
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
15 changes: 14 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
41 changes: 41 additions & 0 deletions .github/workflows/r_upload.yml
Original file line number Diff line number Diff line change
@@ -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/

0 comments on commit 9cbf922

Please sign in to comment.