aboutsummaryrefslogtreecommitdiffstats
path: root/.github/actions/s3cmd/action.yml
blob: a4ebb583555ee4de72fb8e4bf33a5419bc5d5fa0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: configure s3cmd
description: configure s3cmd
inputs:
  s3_key_id:
    required: true
    description: "s3 key id"
  s3_key_secret:
    required: true
    description: "s3 key secret"
  s3_bucket:
    required: true
    description: "s3 bucket"
  s3_endpoint:
    required: true
    description: "s3 endpoint"
  folder_prefix:
    required: true
    description: "folder prefix"
  build_preset:
    required: true
    description: "build preset like relwithdebinfo"
runs:
  using: "composite"
  steps:
    - name: configure s3cmd
      shell: bash
      run: |
        export S3CMD_CONFIG=$(mktemp)
        echo "S3CMD_CONFIG=$S3CMD_CONFIG" >> $GITHUB_ENV
        cat <<EOF > $S3CMD_CONFIG
        [default]
        access_key = ${s3_key_id}
        secret_key = ${s3_secret_access_key}
        bucket_location = ru-central1
        host_base = storage.yandexcloud.net
        host_bucket = %(bucket)s.storage.yandexcloud.net
        EOF
        
        folder="${{ runner.arch == 'X64' && 'x86-64' || runner.arch == 'ARM64' && 'arm64' || 'unknown' }}"
        
        BUILD_PRESET="${{ inputs.build_preset }}"
        
        case "$BUILD_PRESET" in
          relwithdebinfo)
            ;;
          debug)
            folder+="-debug"
            ;;
          release-*)
            folder+="-${BUILD_PRESET/release-/}"
            ;;
          *)
            echo "Invalid preset: ${{ inputs.build_preset }}"
            exit 1
            ;;
        esac
        echo "S3_BUCKET_PATH=s3://${{ inputs.s3_bucket }}/${{ github.repository }}/${{github.workflow}}/${{ github.run_id }}/${{ inputs.folder_prefix }}${folder}" >> $GITHUB_ENV
        echo "S3_URL_PREFIX=${{ inputs.s3_endpoint }}/${{ inputs.s3_bucket }}/${{ github.repository }}/${{ github.workflow }}/${{ github.run_id }}/${{ inputs.folder_prefix }}${folder}" >> $GITHUB_ENV
        echo "S3_TEST_ARTIFACTS_BUCKET_PATH=s3://${{ inputs.s3_bucket }}/testing_out_stuff/${{ github.repository }}/${{github.workflow}}/${{ github.run_id }}/${{ inputs.folder_prefix }}${folder}" >> $GITHUB_ENV
        echo "S3_TEST_ARTIFACTS_URL_PREFIX=${{ inputs.s3_endpoint }}/${{ inputs.s3_bucket }}/testing_out_stuff/${{ github.repository }}/${{ github.workflow }}/${{ github.run_id }}/${{ inputs.folder_prefix }}${folder}" >> $GITHUB_ENV
      env:
        s3_key_id: ${{ inputs.s3_key_id }}
        s3_secret_access_key: ${{ inputs.s3_key_secret }}