This action builds an html preview page from an RO-Crate metadata file.
It can be used in conjunction with other GitHub actions in order to commit the files to your (e.g.) gh-pages branch, and then deploy to your github.io site.
-
Put your
ro-crate-metadata.json
in the root directory of your repo. -
Create a file
.github/workflows/ro-crate-to-ghpages.yml
with the following contents:name: RO-Crate to GitHub Pages on: push: branches: - main jobs: build-and-deploy: runs-on: ubuntu-22.04 concurrency: ci-${{github.ref}} steps: - name: Checkout uses: actions/checkout@v3 - name: Build RO-Crate Preview uses: ResearchObject/ro-crate-preview-action@v1.3.0 - name: Upload artifact uses: actions/upload-pages-artifact@v1 with: # Upload entire repository path: '.' - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v1
The action will run each time you push to the main
branch.
The above workflow has steps to checkout your repo code, build ro-crate-preview.html
,
and commit this to the gh-pages
branch. Note that this workflow will publish the whole of the repository "as-is" without any page rendering.
By default this action looks for ro-crate-metadata.json
in the root of the repository. You can override the path to the RO-Crate root by providing the crate_path
argument:
- name: Build RO Crate Preview
uses: ResearchObject/ro-crate-preview-action@v1.2.0
with:
crate_path: crates/example4
The above will look for crates/example4/ro-crate-metadata.json
and generate crates/example4/ro-crate-preview.html
and the symlink crates/example4/index.html
Instead of publishing the generated RO-Crate preview directly to GitHub Pages, you may prefer
for the ro-crate-preview.html
to be committed back into the main branch. In this way the preview
will also become part of any releases and downloads, such as
Zenodo DOI deposits from GitHub releases.
name: Generate RO-Crate preview
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-22.04
concurrency: ci-${{github.ref}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build RO-Crate Preview
uses: ResearchObject/ro-crate-preview-action@v1.3.0
- name: Commit RO-Crate Preview
uses: swinton/commit@v2.0.0
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
ro-crate-preview.html
index.html
commit-message: |
Updated RO-Crate preview
Note: One downside of this approach is that every push of commits to GitHub
will cause an additional commit back to the repository, which means you will
need to use git pull
to merge your local changes more frequently.