Skip to content
Please note that GitHub no longer supports your web browser.

We recommend upgrading to the latest Google Chrome or Firefox.

Learn more
Permalink
Browse files

Adding Rake task for Portico deposits

  • Loading branch information
arfon committed Sep 27, 2019
1 parent 7384fed commit 701cc47743db4bc9485be031f7805453c994c8c8
Showing with 43 additions and 1 deletion.
  1. +10 −1 app.json
  2. +33 −0 lib/tasks/portico.rake
@@ -22,7 +22,16 @@
},
"GH_TOKEN": {
"description": "The GitHub token for Whedon"
}
},
"PORTICO_HOST": {
"description": "The FTP host for Portico"
},
"PORTICO_USERNAME": {
"description": "The FTP username for Portico"
},
"PORTICO_PASSWORD": {
"description": "The FTP password for Portico"
},
},
"addons": [
"scheduler",
@@ -0,0 +1,33 @@
require 'net/ftp'

namespace :portico do
desc "Deposit"
task deposit: :environment do
Paper.visible.limit(2).each do |paper|
crossref_file = "https://github.com/#{Rails.application.settings["papers_repo"]}/raw/master/#{paper.joss_id}/10.21105.#{paper.joss_id}.crossref.xml"
pdf_file = "https://github.com/#{Rails.application.settings["papers_repo"]}/raw/master/#{paper.joss_id}/10.21105.#{paper.joss_id}.pdf"

files_to_download = [crossref_file, pdf_file]

# Create folder
`mkdir tmp/10.21105.#{paper.joss_id}`

# Download the files into this folder
files_to_download.each do |file|
`cd tmp/10.21105.#{paper.joss_id} && { curl -L -O #{file} ; cd -; }`
end

# Zip the folder
`zip tmp/10.21105.#{paper.joss_id}.zip tmp/10.21105.#{paper.joss_id}/*`

# Upload to FTP server
Net::FTP.open(ENV['PORTICO_HOST'], ENV['PORTICO_USERNAME'], ENV['PORTICO_PASSWORD']) do |ftp|
ftp.putbinaryfile("tmp/10.21105.#{paper.joss_id}.zip")
puts "Uploaded 10.21105.#{paper.joss_id}"
end

# Clean up
`rm -rf tmp/10.21105.#{paper.joss_id}*`
end
end
end

0 comments on commit 701cc47

Please sign in to comment.
You can’t perform that action at this time.