runs-on / cache

Shockingly faster GitHub Action cache with S3 backend
https://runs-on.com
MIT License
53 stars 11 forks source link

Elaborate on Usage outside RunsOn #12

Open joh-klein opened 4 months ago

joh-klein commented 4 months ago

I know this action is primarily for your product – but would you maybe elaborate a little more on how to use it together with the aws-actions/configure-aws-credentials@v4? I specifically want to use your cache action together with minIO but I don't know how to provide the necessary credentials. I get what aws-access-key-id and aws-secret-access-key refer to. But what is aws-region in this case?

joh-klein commented 4 months ago

I got it to work, with some help from @oprypkhantc (thank you 🙏🏼). Basically, don't use aws-actions/configure-aws-credentials@v4 and provide the info directly:

- uses: runs-on/cache@v4
  env:
     RUNS_ON_S3_BUCKET_CACHE: '<cache-name>'
     AWS_ACCESS_KEY_ID: ${{ secrets.MINIO_ROOT_USER }}
     AWS_SECRET_ACCESS_KEY: ${{ secrets.MINIO_ROOT_PASSWORD }}
     AWS_ENDPOINT_URL: 'http://<fqdn-of-minio>:9000'
     AWS_REGION: 'us-east-1'
     AWS_S3_FORCE_PATH_STYLE: 'true'

Since I was using aws for something else in this job already, I had to use different env variables:

- name: Build and push
  uses: docker/build-push-action@v5
  env:
    MINIO_BUCKET: '<cache-name>'
    MINIO_ROOT_USER: ${{ secrets.MINIO_ROOT_USER }}
    MINIO_ROOT_PASSWORD: ${{ secrets.MINIO_ROOT_PASSWORD }}
    MINIO_URL: 'http://<fqdn-of-minio>:9000'
    MINIO_REGION: 'us-east-1'
  with:
    context: .
    push: true
    cache-from: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,use_path_style=true,endpoint_url=${{ env.MINIO_URL }},access_key_id=${{ env.MINIO_ROOT_USER }},secret_access_key=${{ env.MINIO_ROOT_PASSWORD }},region=${{ env.MINIO_REGION }},bucket=${{ env.MINIO_BUCKET }}
    cache-to: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,use_path_style=true,endpoint_url=${{ env.MINIO_URL }},access_key_id=${{ env.MINIO_ROOT_USER }},secret_access_key=${{ env.MINIO_ROOT_PASSWORD }},region=${{ env.MINIO_REGION }},bucket=${{ env.MINIO_BUCKET }},mode=max