action.yml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. name: configure s3cmd
  2. description: configure s3cmd
  3. inputs:
  4. s3_key_id:
  5. required: true
  6. description: "s3 key id"
  7. s3_key_secret:
  8. required: true
  9. description: "s3 key secret"
  10. s3_bucket:
  11. required: false
  12. description: "s3 bucket"
  13. s3_endpoint:
  14. required: true
  15. description: "s3 endpoint"
  16. folder_prefix:
  17. required: false
  18. description: "folder prefix"
  19. build_preset:
  20. required: false
  21. description: "build preset like relwithdebinfo"
  22. runs:
  23. using: "composite"
  24. steps:
  25. - name: configure s3cmd
  26. shell: bash
  27. run: |
  28. export S3CMD_CONFIG=$(mktemp)
  29. echo "S3CMD_CONFIG=$S3CMD_CONFIG" >> $GITHUB_ENV
  30. cat <<EOF > $S3CMD_CONFIG
  31. [default]
  32. access_key = ${s3_key_id}
  33. secret_key = ${s3_secret_access_key}
  34. bucket_location = ru-central1
  35. host_base = storage.yandexcloud.net
  36. host_bucket = %(bucket)s.storage.yandexcloud.net
  37. EOF
  38. # specify mime type for correct content-type in s3cmd sync
  39. # we want to .out/.err files treat as text
  40. MIME_TYPES_LINE="text/plain out err log"
  41. MIME_TYPES_FILE='/etc/mime.types'
  42. # add if not exists
  43. sudo bash -c "grep -qF -- '$MIME_TYPES_LINE' '$MIME_TYPES_FILE' || echo '$MIME_TYPES_LINE' >> '$MIME_TYPES_FILE'"
  44. env:
  45. s3_key_id: ${{ inputs.s3_key_id }}
  46. s3_secret_access_key: ${{ inputs.s3_key_secret }}
  47. - name: export s3 path variables
  48. shell: bash
  49. if: inputs.build_preset
  50. run: |
  51. folder="${{ runner.arch == 'X64' && 'x86-64' || runner.arch == 'ARM64' && 'arm64' || 'unknown' }}"
  52. BUILD_PRESET="${{ inputs.build_preset }}"
  53. case "$BUILD_PRESET" in
  54. relwithdebinfo)
  55. ;;
  56. debug)
  57. folder+="-debug"
  58. ;;
  59. release-*)
  60. folder+="-${BUILD_PRESET/release-/}"
  61. ;;
  62. *)
  63. echo "Invalid preset: ${{ inputs.build_preset }}"
  64. exit 1
  65. ;;
  66. esac
  67. echo "S3_BUCKET_PATH=s3://${{ inputs.s3_bucket }}/${{ github.repository }}/${{github.workflow}}/${{ github.run_id }}/${{ inputs.folder_prefix }}${folder}" >> $GITHUB_ENV
  68. echo "S3_URL_PREFIX=${{ inputs.s3_endpoint }}/${{ inputs.s3_bucket }}/${{ github.repository }}/${{ github.workflow }}/${{ github.run_id }}/${{ inputs.folder_prefix }}${folder}" >> $GITHUB_ENV
  69. 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
  70. 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