Skip to content

FAIR upload

FAIR upload #187

Workflow file for this run

---
name: PFHub Upload
on:
issues:
types: [labeled, edited]
jobs:
pfhub-upload:
# Only run workflow if this is an upload issue
if: ${{ contains(github.event.issue.labels.*.name, 'upload') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Parse the submitted issue
- uses: stefanbuck/github-issue-parser@v2
id: issue-parser
with:
template-path: .github/ISSUE_TEMPLATE/upload.yml
# Write the issue output to a JSON for later use (could have the
# next two steps together
- run: echo '${{ steps.issue-parser.outputs.jsonString }}' > upload.json
# Write the contents of the issue to the environment (it's a
# flat JSON file). It can't have multi-line values so summary is
# done separately
- id: jq
run: jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' upload.json >> $GITHUB_ENV
# Set useful variable used more that once
- run: echo "AUTHOR=${{ github.event.issue.user.login }}" >> $GITHUB_ENV
# Set the short name of the upload
- name: Set the short name of the upload
id: set_short_name
run: |
export tmp=${{ env.doi }}
export short_name=$( echo ${tmp##*/} )
echo "short_name=${short_name}" >> $GITHUB_ENV
# Query the user
- run: curl https://api.github.com/users/${{ env.AUTHOR }} > author.json
# Don't need the JSON file and will be submitted in the PR if
# kept
- run: rm upload.json
# Update the simulation list with the new simulation. Path is
# slightly altered as the python-pfhub is assuming a new
# location.
- run: yq -i '. += "${{ env.doi }}"' _data/simulation_list.yaml
# Create the pull request with a link to the issue that started
# the action. PFHub user generates the PR. The user who
# generated the issue does the commit.
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
id: create-pr
with:
commit-message: "upload: ${{ env.short_name }}"
title: "upload: ${{ env.short_name }}"
body: "adding upload from issue #${{ github.event.issue.number }}"
branch: upload_${{ env.SIMNAME }}_${{ github.event.issue.number }}
token: ${{ secrets.PFHUB_UPLOAD_USER }}
delete-branch: true
author: ${{ env.AUTHOR }} <${{ env.AUTHOR }}@users.noreply.github.com>
# Comment back to the issue with link to the PR.
- name: Create Comment
uses: peter-evans/create-or-update-comment@v2
if: ${{ steps.create-pr.outputs.pull-request-number }}
with:
issue-number: ${{ github.event.issue.number }}
token: ${{ secrets.PFHUB_UPLOAD_USER }}
body: >-
Thanks for the upload! Your submission has opened
pull-request #${{ steps.create-pr.outputs.pull-request-number }}.
Please follow up there. Wait for the build processes to
complete and then follow the posted comments.