-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathFastfile
77 lines (67 loc) · 2.81 KB
/
Fastfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
lane :upload_file do |options|
drive_keyfile = options[:drive_keyfile] || UI.input('Please enter Google Drive keyfile: ')
service_account = options[:service_account] || UI.confirm('Is service account?: ')
folder_id = options[:folder_id] || UI.input('Please enter Google Drive target id: ')
file_to_upload = options[:upload_file] || UI.input('Please enter path for file to upload: ')
upload_to_google_drive(
drive_keyfile: drive_keyfile,
service_account: service_account,
folder_id: folder_id,
upload_files: [file_to_upload]
)
uploaded_file_names = lane_context[SharedValues::GDRIVE_UPLOADED_FILE_NAMES]
UI.message("Uploaded files: #{uploaded_file_names}")
end
lane :create_folder do |options|
drive_keyfile = options[:drive_keyfile] || UI.input('Please enter the path to the keyfile: ')
service_account = options[:service_account] || UI.confirm('Is service account?: ')
parent_folder_id = options[:parent_folder_id] || UI.input('Please enter the parent folder id: ')
folder_title = options[:folder_title] || UI.input('Please enter the folder title to create: ')
find_google_drive_file_by_title(
drive_keyfile: drive_keyfile,
service_account: service_account,
parent_folder_id: parent_folder_id,
file_title: folder_title
)
if lane_context[SharedValues::GDRIVE_FILE_ID]
UI.message("The folder already exists with given id.")
else
create_google_drive_folder(
drive_keyfile: drive_keyfile,
service_account: service_account,
parent_folder_id: parent_folder_id,
folder_title: folder_title
)
end
UI.message("Created folder id: #{lane_context[SharedValues::GDRIVE_FILE_ID]}")
end
lane :upload_or_replace_file do |options|
drive_keyfile = options[:drive_keyfile] || UI.input('Please enter the path to the keyfile: ')
service_account = options[:service_account] || UI.confirm('Is service account?: ')
parent_folder_id = options[:parent_folder_id] || UI.input('Please enter the parent folder id: ')
file_to_upload = options[:upload_file] || UI.input('Please enter the path to the file: ')
find_google_drive_file_by_title(
drive_keyfile: drive_keyfile,
service_account: service_account,
parent_folder_id: parent_folder_id,
file_title: File.basename(file_to_upload)
)
existing_file_id = lane_context[SharedValues::GDRIVE_FILE_ID]
if existing_file_id
UI.message("Replace existing file.")
update_google_drive_file(
drive_keyfile: drive_keyfile,
service_account: service_account,
file_id: existing_file_id,
upload_file: file_to_upload
)
else
upload_to_google_drive(
drive_keyfile: drive_keyfile,
service_account: service_account,
folder_id: parent_folder_id,
upload_files: [file_to_upload]
)
end
UI.message("Uploaded file id: #{lane_context[SharedValues::GDRIVE_FILE_ID]}")
end