tespkg / actions-cache

Cache to S3 storage with official actions/cache@v2 fallback
MIT License
75 stars 31 forks source link

Is there a way to delete cached objects explicitly? #33

Closed joernott closed 1 year ago

joernott commented 1 year ago

Is your feature request related to a problem? Please describe.

Usually, people just create/update cached objects and don't care about them afterwards. I create some cached objects before running a specific test suite. After finishing those tests, these cached objects are no longer needed. Theoretically, they might even contain some sensitive data. Mine doesn't, but it's just an easy misconfiguration away.

Describe the solution you'd like

I would like to be avle to explicitly remove a cached object by specifying its key:

  steps:
    - name: Remove cached object from cache
      id: load_installed_shop
      uses: tespkg/actions-cache@v1
      with:
        path: |
          ./*
        key: ${{ inputs.key }}
        delete-keys: |
          ${{ inputs.key }}
        endpoint: ${{ secrets.cache_endpoint }}
        accessKey: ${{ secrets.cache_access_key }}
        secretKey: ${{ secrets.cache_secret_key }}
        bucket: test-suite

Describe alternatives you've considered

Figuring out the REST API calls for S3 and github cache API and do the deletes via curl calls

Additional context

tvthatsme commented 1 year ago

You can use a different action for that without too much trouble. I am using keithweaver/aws-s3-github-action with good results. At the end of the workflow this cleans up artifacts that I don't need to keep around.

  - name: Cleanup artifacts in S3
    uses: keithweaver/aws-s3-github-action@v1.0.0
      with:
        command: rm
        source: s3://your-bucket
        aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        aws_region: us-east-1
        flags: --recursive
jackieli-tes commented 1 year ago

Thanks @tvthatsme . Using a different action is the way to go