Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not make assumptions about files in HMRC PAYE task #585

Merged
merged 2 commits into from Aug 3, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 7 additions & 23 deletions lib/tasks/govuk_assets.rake
Expand Up @@ -31,34 +31,18 @@ namespace :govuk_assets do
puts "Uploaded '#{file_path}' to '#{legacy_url_path}'"
end

desc 'Store HMRC PAYE files, from the given directory'
task :create_hmrc_paye_assets, %i[directory version] => :environment do |_, args|
directory = args[:directory]
version_full = args[:version]
version_short = version_full.split('.')[0]

desc 'Upload a file to /government/uploads/uploaded/hmrc. The optional second argument is the filename to use.'
task :create_hmrc_paye_asset, %i[file_path] => :environment do |_, args|
hmrc_url_base = '/government/uploads/uploaded/hmrc'

manifest_basename = "realtimepayetools-update-v#{version_short}.xml"
manifest_path = File.join(directory, manifest_basename)
test_manifest_legacy_url_path = "#{hmrc_url_base}/test-#{manifest_basename}"
file_path = args[:file_path]

[
'payetools-linux.zip',
'payetools-osx.zip',
'payetools-windows.zip',
"payetools-rti-#{version_full}-linux.zip",
"payetools-rti-#{version_full}-osx.zip",
"payetools-rti-#{version_full}-windows.zip",
].each do |basename|
create_or_replace_whitehall_asset(File.join(directory, basename), "#{hmrc_url_base}/#{basename}")
basename = File.basename(file_path)
if args.extras.count.positive?
basename = args.extras[0]
end

create_or_replace_whitehall_asset(manifest_path, test_manifest_legacy_url_path)

puts ''
puts "If there are any other files to upload, use 'rake govuk_assets:create_whitehall_asset[/path/to/file.ext,#{hmrc_url_base}/file.ext]'."
puts "Run 'rake govuk_assets:create_whitehall_asset[#{manifest_path},#{hmrc_url_base}/#{manifest_basename}]' to store the file to the real URL after it is confirmed to work."
create_or_replace_whitehall_asset(file_path, "#{hmrc_url_base}/#{basename}")
end

desc 'Create a whitehall asset with the given legacy URL path'
Expand Down