name: Upload Package All artifacts to S3

on:
  workflow_dispatch:
    inputs:
      memgraph_version:
        description: "Memgraph version to upload as. Format: 'X.Y.Z'"
        required: true
      run_number:
        description: "# of the package_all workflow run to upload artifacts from. Format: '#XYZ'"
        required: true

jobs:
  upload-to-s3:
    runs-on: ubuntu-latest
    steps:
      - name: Download artifacts
        uses: dawidd6/action-download-artifact@v4
        with:
          workflow: package_all.yaml
          workflow_conclusion: success
          run_number: "${{ github.event.inputs.run_number }}"
          path: build/output/release
      - name: Upload to S3
        uses: jakejarvis/s3-sync-action@v0.5.1
        env:
          AWS_S3_BUCKET: "download.memgraph.com"
          AWS_ACCESS_KEY_ID: ${{ secrets.S3_AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_AWS_SECRET_ACCESS_KEY }}
          AWS_REGION: "eu-west-1"
          SOURCE_DIR: "build/output/release"
          DEST_DIR: "memgraph/v${{ github.event.inputs.memgraph_version }}/"
