12-02-2024
Laura Huis in ‘t Veld
Dataverse version 6.0
From the User Guide:
Dataverse integration with GitHub is implemented via a Dataverse Uploader GitHub Action. It is a reusable, composite workflow for uploading a git repository or subdirectory into a dataset on a target Dataverse installation. The action is customizable, allowing users to choose to replace a dataset, add to the dataset, publish it or leave it as a draft version on Dataverse. The action provides some metadata to the dataset, such as the origin GitHub repository, and it preserves the directory tree structure.
For instructions on using Dataverse Uploader GitHub Action, visit https://github.com/marketplace/actions/dataverse-uploader-action
Dataverse Uploader Github Action was developed by Ana Trisovic.
https://github.com/IQSS/dataverse-uploader/blob/master/LICENSE
You will need:
The url of the dataverse instance, for example ‘https://dataverse.nl”
The DOI of the dataset where you would like to upload your files
Your dataverse API token. (In Dataverse, click on your username and choose ‘API token’ from the dropdown menu to view your API token or to create one.)
Steps
Go to the Github repository from where you would like to deposit in dataverse.
Create a new .yml file in .github/workflows. Paste one of the code examples from https://github.com/marketplace/actions/dataverse-uploader-action
For example:
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Send repo to Dataverse
uses: IQSS/dataverse-uploader@v1.4
with:
DATAVERSE_TOKEN: ${{secrets.DATAVERSE_TOKEN}}
DATAVERSE_SERVER: https://demo.dataverse.org
DATAVERSE_DATASET_DOI: doi:10.70122/FK2/LVUA
DELETE: False
Change the value of DATAVERSE_SERVER to match the url of your dataverse instance.
Change the value of DATAVERSE_DATASET_DOI to match your dataset DOI.
Store your Dataverse API token as a secret in your repository.
Go to ‘Settings’ and click on ‘secrets and Variables>actions’ on the left panel.
Click ‘New Repository secret’
Name your secret ‘DATAVERSE_TOKEN.
Store your Dataverse API Token in the value field and add the secret.
If you would like to upload only part of your files to dataverse, you can indicate from which subdirectory files should be deposited into dataverse.
To do this add:
GITHUB_DIR: <name of subdirectory>If you want your dataset to be published directly after the upload of your files, add
PUBLISH: TrueBy default, the action will sync the GitHub repository and the Dataverse dataset, meaning that it will delete the Dataverse content before uploading the content from GitHub. If you don't want the action to delete your dataset before upload (i.e., if you already have a Dataverse DRAFT dataset), add
DELETE: FalseSelect the workflow you have created and choose 'View Runs> ‘Run workflow’. Your files will now be uploaded to the dataset.
If you want the workflow to be triggered automatically, you can choose to run the workflow on
release
push
Display the DOI of your dataset in Github
If you would like to display the DOI of your dataset in Github, you can use this badge generator:
https://atrisovic.github.io/dataverse-badge/
For example, you can paste the html snippet with the DOI badge in the readMe file of your repository.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article