Skip to content

Commit

Permalink
project-page-pull-request: Simplify using jq and input as "data file"
Browse files Browse the repository at this point in the history
  • Loading branch information
jcfr committed May 23, 2023
1 parent e8dd553 commit fe6a350
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 43 deletions.
55 changes: 18 additions & 37 deletions .github/workflows/project-page-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,49 +110,30 @@ jobs:
- name: Extract issue fields
id: extract
run: |
function set_multiline_output_param() {
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "$1<<$EOF" >> $GITHUB_OUTPUT
echo "$2" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
}
category=$(echo ${{ toJSON(steps.parse.outputs.data) }} | jq '."category".text')
echo "category=$category" >> $GITHUB_OUTPUT
description=$(echo ${{ toJSON(steps.parse.outputs.data) }} | jq '."project-description".text')
set_multiline_output_param "description" "$description"
objective=$(echo ${{ toJSON(steps.parse.outputs.data) }} | jq '.objective.text')
set_multiline_output_param "objective" "$objective"
approach=$(echo ${{ toJSON(steps.parse.outputs.data) }} | jq '."approach-and-plan".text')
set_multiline_output_param "approach" "$approach"
progress=$(echo ${{ toJSON(steps.parse.outputs.data) }} | jq '."progress-and-next-steps".text')
set_multiline_output_param "progress" "$progress"
illustrations=$(echo ${{ toJSON(steps.parse.outputs.data) }} | jq '.illustrations.text')
set_multiline_output_param "illustrations" "$illustrations"
background=$(echo ${{ toJSON(steps.parse.outputs.data) }} | jq '."background-and-references".text')
set_multiline_output_param "background" "$background"
echo ${{ toJSON(steps.parse.outputs.data) }} | \
jq --arg title "${{ steps.project_issue.outputs.title }}" '{
"title": $title,
"category": .category.text,
"key-investigators": [.["key-investigators"].list[].text],
"description": .["project-description"].text,
"objective": .objective.text,
"approach": .["approach-and-plan"].text,
"progress": .["progress-and-next-steps"].text,
"illustrations": .illustrations.text,
"background": .["background-and-references"].text
}' > template-data.json
- name: Generate Project README.md
uses: cuchi/[email protected]
with:
template: ${{ steps.event_info.outputs.name }}/Projects/Template/README.md.j2
output_file: ${{ steps.event_info.outputs.name }}/Projects/${{ steps.project_directory.outputs.name }}/README.md
strict: true
variables: |
title=${{ steps.project_issue.outputs.title }}
category=${{ steps.extract.outputs.category }}
description=${{ steps.extract.outputs.description }}
objective=${{ steps.extract.outputs.objective }}
approach=${{ steps.extract.outputs.approach }}
progress=${{ steps.extract.outputs.progress }}
illustrations=${{ steps.extract.outputs.illustrations }}
background=${{ steps.extract.outputs.background }}
data_file: template-data.json
data_format: json

- name: Cleanup
run: |
rm template-data.json
- uses: tibdex/github-app-token@v1
id: generate-token
Expand Down
12 changes: 6 additions & 6 deletions PW39_2023_Montreal/Projects/Template/README.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,36 @@ key_investigators:

<!-- Add a short paragraph describing the project. -->

{{ description[1:-1] }}
{{ description }}

## Objective

<!-- Describe here WHAT you would like to achieve (what you will have as end result). -->

{{ objective[1:-1] }}
{{ objective }}

## Approach and Plan

<!-- Describe here HOW you would like to achieve the objectives stated above. -->

{{ approach[1:-1] }}
{{ approach }}

## Progress and Next Steps

<!-- Update this section as you make progress, describing of what you have ACTUALLY DONE.
If there are specific steps that you could not complete then you can describe them here, too. -->

{{ progress[1:-1] }}
{{ progress }}

# Illustrations

<!-- Add pictures and links to videos that demonstrate what has been accomplished. -->

{{ illustrations[1:-1] }}
{{ illustrations }}

# Background and References

<!-- If you developed any software, include link to the source code repository.
If possible, also add links to sample data, and to any relevant publications. -->

{{ background[1:-1] }}
{{ background }}

0 comments on commit fe6a350

Please sign in to comment.