shallwefootball / upload-s3-action

github action for upload to S3 ☁️
https://github.com/marketplace/actions/upload-s3
166 stars 158 forks source link

Ability to set path style for buckets #68

Open Folleach opened 5 months ago

Folleach commented 5 months ago

I've self-hosted s3 service that does not support specifies buckets by domain.
But it supports path style buckets, like this: https://s3.example.net/{bucket}/

When I tried to use this action for site bucket at the s3.example.net, I got an error

Error: UnknownEndpoint: Inaccessible host: `site.s3.example.net' at port `undefined'. This service may not be available in the `us-east-1' region.

After research the aws-sdk library led me to the s3ForcePathStyle field which allows to change this behavior.

So, I added this field as force_path_style to action and changed workflow:

 - uses: shallwefootball/s3-upload-action@master
   with:
     aws_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
     aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
     aws_bucket: site
     source_dir: ./client/build
     destination_dir: public
     endpoint: https://s3.example.net/
+    force_path_style: true

Now it works well!
The only thing is... I'm newbie at the object storage, maybe I could achieve the same goal in an alternative way?