Skip to content

Commit 0b12a2f

Browse files
committed
feat,ci: refactor hermes workflow with Software CaRD stub
1 parent 54f5222 commit 0b12a2f

1 file changed

Lines changed: 32 additions & 85 deletions

File tree

.github/workflows/hermes_github.yml

Lines changed: 32 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -28,105 +28,52 @@ jobs:
2828
)
2929
3030
permissions:
31-
contents: write # Allow creation of new branches
32-
pull-requests: write # Postprocessing should be able to create a pull request with changes
31+
contents: read
32+
issues: write # Allow creating new issues with the reports from Software CaRD
3333

3434
steps:
35-
- uses: actions/checkout@v3
36-
- uses: actions/setup-python@v4
35+
- uses: actions/checkout@v6
36+
- uses: actions/setup-python@v6
3737
with:
38-
python-version: '3.10'
38+
python-version: '3.12'
3939
- run: pip install hermes
4040
- run: pip install git+https://github.com/softwarepub/hermes-plugin-git
4141

4242
- run: hermes harvest
4343
- run: hermes process
44-
- run: hermes curate
4544

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
45+
# This is where we will run the Software CaRD plugin (later)
46+
# - run: hermes curate
9147

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
48+
# Create a stub report
49+
- run: |
50+
mkdir -p .hermes/curate
51+
echo '{"test": "foobar"}' > .hermes/curate/report
9752
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
53+
# Upload artifact (there are no real file attachments for issues and the max length may impose problems later, so we can't just use a <details> tag)
54+
- id: upload-report
55+
uses: actions/upload-artifact@v6
10156
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
57+
name: softwarecard-report
58+
path: ./hermes/curation/*
59+
if-no-files-found: 'error'
60+
retention-days: 90
61+
- run: 'echo Report artifact accessible at ${{ steps.upload-report.outputs.artifact-url }}'
10962

110-
# Delete all the curation branches
11163
- 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
64+
echo 'This is a stub message for Software CaRD report.' | tee -a report.md
65+
echo 'Report artifact at ${{ steps.upload-report.outputs.artifact-url }}' | tee -a report.md
66+
echo 'Rendered view at https://softwarepub.github.io/software-card/index.html?type=github&repoUrl=${{ github.repositoryUrl }}&artifactUrl=${{ steps.upload-report.outputs.artifact-url }}' | tee -a report.md
11567
68+
# Now create an issue and add the Software CaRD report
69+
- name: Create Issue From File
70+
uses: peter-evans/create-issue-from-file@v6
71+
with:
72+
title: An example issue
73+
content-filepath: ./report.md
74+
#labels: |
75+
# report
76+
# automated issue
77+
- run: 'echo Created report in issue #${{ steps.create-report-issue.outputs.issue-number }}'
11678

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
12579

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

0 commit comments

Comments
 (0)