Skip to content

Commit 6c2c0a4

Browse files
committed
add parse for multiple dirs
1 parent 4006776 commit 6c2c0a4

File tree

2 files changed

+45
-20
lines changed

2 files changed

+45
-20
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ steps:
6060
GITHUB_DIR: data
6161
```
6262

63+
You can upload multiple subdirectories (only) by listing them as `GITHUB_DIR` in the following format:
64+
65+
```
66+
steps:
67+
- name: Send repo to Dataverse
68+
uses: IQSS/dataverse-uploader@v1.2
69+
with:
70+
DATAVERSE_TOKEN: ${{secrets.DATAVERSE_TOKEN}}
71+
DATAVERSE_SERVER: https://demo.dataverse.org
72+
DATAVERSE_DATASET_DOI: doi:10.70122/FK2/LVUA
73+
GITHUB_DIR: |
74+
data
75+
plots
76+
```
77+
6378
By default, the action will sync the GitHub repository and the Dataverse dataset, meaning that it will
6479
delete the Dataverse content before uploading the content from GitHub. If you don't want the action to
6580
delete your dataset before upload (i.e., if you already have a Dataverse `DRAFT` dataset),
@@ -104,6 +119,10 @@ is triggered with every `push` to the GitHub repository, it will automatically u
104119
Dataverse. You specify the action triggers in the workflow (`.yml`) file, and in this case, it would
105120
contain `on: push` line to execute the action on every push to the repository.
106121

122+
> Will the action work with dataset Handles as persistent identifiers (PIDs) instead of DOIs?
123+
124+
Yes, the action uses Dataverse API that supports both DOIs and Handles for retrieving and uploading data.
125+
107126
## Related projects
108127

109128
Check out the following related projects:

dataverse.py

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,27 +71,33 @@ def check_dataset_lock(num):
7171
delete_api + str(fileid), \
7272
auth = (token , ""))
7373

74-
# the following adds all files from the repository to Dataverse
75-
path = join('repo',args.dir) if args.dir else 'repo'
74+
# check if there is a list of dirs to upload
75+
paths = ['repo']
76+
if args.dir:
77+
dirs = args.dir.strip().replace(",", " ")
78+
dirs = dirs.split()
79+
paths = [join('repo', d) for d in dirs]
7680

77-
for root, subdirs, files in walk(path):
78-
if '.git' in subdirs:
79-
subdirs.remove('.git')
80-
if '.github' in subdirs:
81-
subdirs.remove('.github')
82-
for f in files:
83-
df = Datafile()
84-
df.set({
85-
"pid" : args.doi,
86-
"filename" : f,
87-
"directoryLabel": root[5:],
88-
"description" : \
89-
"Uploaded with GitHub Action from {}.".format(
90-
args.repo),
91-
})
92-
resp = api.upload_datafile(
93-
args.doi, join(root,f), df.json())
94-
check_dataset_lock(5)
81+
# the following adds all files from the repository to Dataverse
82+
for path in paths:
83+
for root, subdirs, files in walk(path):
84+
if '.git' in subdirs:
85+
subdirs.remove('.git')
86+
if '.github' in subdirs:
87+
subdirs.remove('.github')
88+
for f in files:
89+
df = Datafile()
90+
df.set({
91+
"pid" : args.doi,
92+
"filename" : f,
93+
"directoryLabel": root[5:],
94+
"description" : \
95+
"Uploaded with GitHub Action from {}.".format(
96+
args.repo),
97+
})
98+
resp = api.upload_datafile(
99+
args.doi, join(root,f), df.json())
100+
check_dataset_lock(5)
95101

96102
if args.publish.lower() == 'true':
97103
# publish updated dataset

0 commit comments

Comments
 (0)