github icon indicating copy to clipboard operation
github copied to clipboard

github asset download force does not force

Open axos88 opened this issue 11 months ago • 0 comments

Probably a documentation bug: Setting force to true only has an effect when the action is extract

The desired behaviour however is to force downloading the asset, since in our case the assets get updated. The ideal solution for my use case would be a similar behaviour as remote_file, which can notify if the asset has changed. My current workaround is this:

Also it would be great if the download location could be read from the resource, such as asset.file_path, or alike.

asset = github_asset 'frontend.tar.gz' do
  github_user 'axos88'
  github_token EncryptedCache.fetch('doorlock_github_token')
  owner 'www-data'
  group 'www-data'

  repo 'org/project'
  release 'vLatest'
  action :download
  force true
end

frontend_path = File.join(Chef::Config['file_cache_path'], 'project-frontend.tar.gz')

remote_file frontend_path do
  source "file://#{Chef::Config['file_cache_path']}/github_assets/org/project/vLatest/frontend.tar.gz" #TODO: Extract path from resource definition.
  notifies :extract, "archive_file[#{frontend_path}]", :immediately
end

axos88 avatar Mar 12 '25 10:03 axos88