Skip to content

Commit 54f5222

Browse files
committed
Initial commit
0 parents  commit 54f5222

5 files changed

Lines changed: 151 additions & 0 deletions

File tree

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# SPDX-FileCopyrightText: 2023 German Aerospace Center (DLR), Forschungszentrum Jülich, Helmholtz-Zentrum Dresden-Rossendorf
2+
#
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
6+
name: Software Publication
7+
8+
on:
9+
# This trigger on branches being pushed starts the HERMES pipeline.
10+
push:
11+
branches:
12+
- main
13+
14+
# This trigger on closed pull requests is mandatory for the rest of the HERMES workflow.
15+
pull_request:
16+
types:
17+
- closed
18+
19+
jobs:
20+
hermes-prepare:
21+
name: Prepare Metadata for Curation
22+
runs-on: ubuntu-latest
23+
24+
if: >
25+
github.event_name == 'push' && ! (
26+
startsWith(github.ref_name, 'hermes/') ||
27+
contains(github.event.head_commit.message, 'hermes/post')
28+
)
29+
30+
permissions:
31+
contents: write # Allow creation of new branches
32+
pull-requests: write # Postprocessing should be able to create a pull request with changes
33+
34+
steps:
35+
- uses: actions/checkout@v3
36+
- uses: actions/setup-python@v4
37+
with:
38+
python-version: '3.10'
39+
- run: pip install hermes
40+
- run: pip install git+https://github.com/softwarepub/hermes-plugin-git
41+
42+
- run: hermes harvest
43+
- run: hermes process
44+
- run: hermes curate
45+
46+
- run: |
47+
# Cache current branch for PR close job
48+
git branch --show-current > .hermes/curate/target_branch
49+
50+
# Shorten the SHA for the PR title
51+
SHORT_SHA=$(echo "$GITHUB_SHA" | cut -c -8)
52+
echo "SHORT_SHA=$SHORT_SHA" >> "$GITHUB_ENV"
53+
54+
# Create a curation branch
55+
git branch -c "hermes/curate-$SHORT_SHA"
56+
git push origin "hermes/curate-$SHORT_SHA"
57+
58+
# Explicitly add to-be-curated metadata (which is ignored via .gitignore!)
59+
git add -f .hermes/curate
60+
- uses: peter-evans/create-pull-request@v7
61+
with:
62+
base: hermes/curate-${{ env.SHORT_SHA }}
63+
branch: hermes/curate-result-${{ env.SHORT_SHA }}
64+
title: Metadata Curation for Commit ${{ env.SHORT_SHA }}
65+
body: |
66+
Please carefully review the attached metadata.
67+
If you are satisfied with the result, you may merge this PR, which will trigger publication.
68+
(Any temporary branches will be cleaned up.)
69+
delete-branch: true
70+
71+
hermes-curate:
72+
name: Publish Software with Curated Metadata
73+
if: github.event.pull_request.merged == true && startsWith( github.base_ref , 'hermes/curate-')
74+
75+
runs-on: ubuntu-latest
76+
permissions:
77+
contents: write # Allow creation of new branches
78+
pull-requests: write # Postprocessing should be able to create a pull request with changes
79+
80+
steps:
81+
- uses: actions/checkout@v4
82+
- uses: actions/setup-python@v5
83+
with:
84+
python-version: '3.10'
85+
- run: pip install hermes
86+
- run: pip install git+https://github.com/softwarepub/hermes-plugin-git
87+
88+
89+
# Archive the artifacts that will be published
90+
- run: git archive --format zip HEAD - > artifact.zip
91+
92+
# Run the HERMES deposition step
93+
- run: hermes deposit --initial -O invenio_rdm.auth_token ${{ secrets.ZENODO_SANDBOX_TOKEN }} --file artifact.zip --file README.md
94+
95+
# Run the HERMES postprocess step
96+
- run: hermes postprocess
97+
98+
# Create pull request to include the post-processing results
99+
- run: echo "TARGET_BRANCH=$(cat .hermes/curate/target_branch)" >> "$GITHUB_ENV"
100+
- uses: peter-evans/create-pull-request@v5
101+
with:
102+
branch: hermes/post-${{ github.run_id }}
103+
base: ${{ env.TARGET_BRANCH }}
104+
title: Review hermes post-processing results
105+
body: |
106+
This is an automated pull request created by HERMES post-processing.
107+
108+
Please carefully review the changes and finally merge them into your
109+
110+
# Delete all the curation branches
111+
- run: |
112+
for BRANCH in $(git ls-remote origin 'refs/heads/hermes/curate-*' | cut -f2 | cut -d'/' -f'3-'); do
113+
git push origin --delete "$BRANCH"
114+
done
115+
116+
117+
hermes-cleanup:
118+
name: Cleanup aborted curation branches
119+
if: github.event.pull_request.merged == false && startsWith( github.base_ref , 'hermes/curate-')
120+
121+
runs-on: ubuntu-latest
122+
permissions:
123+
contents: write # Allow creation of new branches
124+
pull-requests: write # Postprocessing should be able to create a pull request with changes
125+
126+
steps:
127+
- uses: actions/checkout@v4
128+
# Delete all the curation branches
129+
- run: |
130+
for BRANCH in $(git ls-remote origin 'refs/heads/hermes/curate-*' | cut -f2 | cut -d'/' -f'3-'); do
131+
git push origin --delete "$BRANCH"
132+
done

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Ignoring all HERMES cache files
2+
.hermes/
3+
hermes.log
4+
5+
# IDEs
6+
.idea/

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This is a stub
2+
3+
We will need to fill this with more content later for a proper showcase.

hermes.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[harvest]
2+
sources = [ "cff", "git",]
3+
4+
[deposit]
5+
target = "invenio_rdm"
6+
7+
[deposit.invenio_rdm]
8+
site_url = "https://sandbox.zenodo.org/"
9+
access_right = "open"

src/test.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This is a humble placeholder

0 commit comments

Comments
 (0)