Initial commit #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-FileCopyrightText: 2023 German Aerospace Center (DLR), Forschungszentrum Jülich, Helmholtz-Zentrum Dresden-Rossendorf | |
| # | |
| # SPDX-License-Identifier: CC0-1.0 | |
| name: Software Publication | |
| on: | |
| # This trigger on branches being pushed starts the HERMES pipeline. | |
| push: | |
| branches: | |
| - main | |
| # This trigger on closed pull requests is mandatory for the rest of the HERMES workflow. | |
| pull_request: | |
| types: | |
| - closed | |
| jobs: | |
| hermes-prepare: | |
| name: Prepare Metadata for Curation | |
| runs-on: ubuntu-latest | |
| if: > | |
| github.event_name == 'push' && ! ( | |
| startsWith(github.ref_name, 'hermes/') || | |
| contains(github.event.head_commit.message, 'hermes/post') | |
| ) | |
| permissions: | |
| contents: write # Allow creation of new branches | |
| pull-requests: write # Postprocessing should be able to create a pull request with changes | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - run: pip install hermes | |
| - run: pip install git+https://github.com/softwarepub/hermes-plugin-git | |
| - run: hermes harvest | |
| - run: hermes process | |
| - run: hermes curate | |
| - run: | | |
| # Cache current branch for PR close job | |
| git branch --show-current > .hermes/curate/target_branch | |
| # Shorten the SHA for the PR title | |
| SHORT_SHA=$(echo "$GITHUB_SHA" | cut -c -8) | |
| echo "SHORT_SHA=$SHORT_SHA" >> "$GITHUB_ENV" | |
| # Create a curation branch | |
| git branch -c "hermes/curate-$SHORT_SHA" | |
| git push origin "hermes/curate-$SHORT_SHA" | |
| # Explicitly add to-be-curated metadata (which is ignored via .gitignore!) | |
| git add -f .hermes/curate | |
| - uses: peter-evans/create-pull-request@v7 | |
| with: | |
| base: hermes/curate-${{ env.SHORT_SHA }} | |
| branch: hermes/curate-result-${{ env.SHORT_SHA }} | |
| title: Metadata Curation for Commit ${{ env.SHORT_SHA }} | |
| body: | | |
| Please carefully review the attached metadata. | |
| If you are satisfied with the result, you may merge this PR, which will trigger publication. | |
| (Any temporary branches will be cleaned up.) | |
| delete-branch: true | |
| hermes-curate: | |
| name: Publish Software with Curated Metadata | |
| if: github.event.pull_request.merged == true && startsWith( github.base_ref , 'hermes/curate-') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Allow creation of new branches | |
| pull-requests: write # Postprocessing should be able to create a pull request with changes | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - run: pip install hermes | |
| - run: pip install git+https://github.com/softwarepub/hermes-plugin-git | |
| # Archive the artifacts that will be published | |
| - run: git archive --format zip HEAD - > artifact.zip | |
| # Run the HERMES deposition step | |
| - run: hermes deposit --initial -O invenio_rdm.auth_token ${{ secrets.ZENODO_SANDBOX_TOKEN }} --file artifact.zip --file README.md | |
| # Run the HERMES postprocess step | |
| - run: hermes postprocess | |
| # Create pull request to include the post-processing results | |
| - run: echo "TARGET_BRANCH=$(cat .hermes/curate/target_branch)" >> "$GITHUB_ENV" | |
| - uses: peter-evans/create-pull-request@v5 | |
| with: | |
| branch: hermes/post-${{ github.run_id }} | |
| base: ${{ env.TARGET_BRANCH }} | |
| title: Review hermes post-processing results | |
| body: | | |
| This is an automated pull request created by HERMES post-processing. | |
| Please carefully review the changes and finally merge them into your | |
| # Delete all the curation branches | |
| - run: | | |
| for BRANCH in $(git ls-remote origin 'refs/heads/hermes/curate-*' | cut -f2 | cut -d'/' -f'3-'); do | |
| git push origin --delete "$BRANCH" | |
| done | |
| hermes-cleanup: | |
| name: Cleanup aborted curation branches | |
| if: github.event.pull_request.merged == false && startsWith( github.base_ref , 'hermes/curate-') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Allow creation of new branches | |
| pull-requests: write # Postprocessing should be able to create a pull request with changes | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Delete all the curation branches | |
| - run: | | |
| for BRANCH in $(git ls-remote origin 'refs/heads/hermes/curate-*' | cut -f2 | cut -d'/' -f'3-'); do | |
| git push origin --delete "$BRANCH" | |
| done |