Skip to content

3D Cuboid Segmentation Aggregation #578

3D Cuboid Segmentation Aggregation

3D Cuboid Segmentation Aggregation #578

name: Project Page Pull Request Creation
on:
issues:
types: [ labeled ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
if: github.event.label.name == 'project:create'
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Fetch the project issue info
id: project_issue
env:
GH_TOKEN: ${{ github.token }}
run: |
title=$(gh issue view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json title --jq '.title')
echo "title [$title]"
# If any, remove"Project:" prefix
title=$(echo "$title" | sed 's/^Project:\s*//')
echo "title [$title]"
echo "title=$title" >> $GITHUB_OUTPUT
- name: Find project issue comment
uses: peter-evans/find-comment@v2.4.0
id: fc
with:
issue-number: ${{ github.event.issue.number }}
comment-author: 'github-actions[bot]'
body-includes: Project Page Pull Request Creation
- name: Create or update comment ⌛
id: couc
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.issue.number }}
body: |
## Project Page Pull Request Creation
:hourglass: **IN PROGRESS**: ![Project Page Pull Request Creation](${{ github.server_url }}/${{ github.repository }}/actions/workflows/project-page-pull-request.yml/badge.svg)
edit-mode: replace
- name: Extract event info
id: event_info
run: |
# TODO: Extract event name from "event:NAME" label
event_name="PW41_2024_MIT"
echo "name=$event_name" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
- name: Generate project directory name
id: project_directory
run: |
title=$(echo ${{ steps.project_issue.outputs.title }})
echo "title [$title]"
# Convert to title case
title_cased=$(echo "$title" | sed 's/.*/\L&/; s/[a-z]*/\u&/g')
echo "title_cased [$title_cased]"
# Sanitize string to use as a directory name
directory_name=$(echo "$title_cased" | tr -cs '[:alnum:]' '_' | sed 's/_//g')
echo "directory_name [$directory_name]"
echo "name=$directory_name" >> $GITHUB_OUTPUT
- name: Check if project already exists
id: check_project_exists
run: |
event_name=${{ steps.event_info.outputs.name }}
project_directory=${{ steps.event_info.outputs.name }}/Projects/${{ steps.project_directory.outputs.name }}
if [ -d "$project_directory" ]; then
echo "::error::Project already exist"
exit 1
fi
- name: Create or update comment 🛑
if: ${{ failure() && steps.check_project_exists.outcome == 'failure' }}
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.couc.outputs.comment-id }}
issue-number: ${{ github.event.issue.number }}
body: |
## Project Page Pull Request Creation
:stop_sign: **STOPPED**: Project already exists
edit-mode: replace
- name: Create project directory
run: |
event_name=${{ steps.event_info.outputs.name }}
directory_name=${{ steps.project_directory.outputs.name }}
mkdir $event_name/Projects/$directory_name
- name: Bulk issue body
id: bulk
env:
GH_TOKEN: ${{ github.token }}
run: |
body=$(gh issue view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json body --jq '.body')
echo "$body" > ${{ runner.temp }}/bulk.txt
- name: Display bulk.txt
run: |
cat ${{ runner.temp }}/bulk.txt
- name: Split bulk
run: |
csplit ${{ runner.temp }}/bulk.txt \
'/^### Project Description/' \
'/^### Objective/' \
'/^### Approach and Plan/' \
'/^### Progress and Next Steps/' \
'/^### Illustrations/' \
'/^### Background and References/' \
-f ${{ runner.temp }}/project_pull_request_part_ -b "%02d.md"
- name: Cleanup files
run: |
cat ${{ runner.temp }}/project_pull_request_part_01.md | sed "1 d" > ${{ runner.temp }}/description.md
cat ${{ runner.temp }}/project_pull_request_part_02.md | sed "1 d" > ${{ runner.temp }}/objective.md
cat ${{ runner.temp }}/project_pull_request_part_03.md | sed "1 d" > ${{ runner.temp }}/approach.md
cat ${{ runner.temp }}/project_pull_request_part_04.md | sed "1 d" > ${{ runner.temp }}/progress.md
cat ${{ runner.temp }}/project_pull_request_part_05.md | sed "1 d" > ${{ runner.temp }}/illustrations.md
cat ${{ runner.temp }}/project_pull_request_part_06.md | sed "1 d" > ${{ runner.temp }}/background.md
- name: Display clean files
run: |
echo "Description:"
cat ${{ runner.temp }}/description.md
echo "Objective:"
cat ${{ runner.temp }}/objective.md
echo "Approach:"
cat ${{ runner.temp }}/approach.md
echo "Progress:"
cat ${{ runner.temp }}/progress.md
echo "Illustrations:"
cat ${{ runner.temp }}/illustrations.md
echo "Background:"
cat ${{ runner.temp }}/background.md
- name: Issue Forms Body Parser
id: parse
uses: zentered/issue-forms-body-parser@v2.0.0
- name: Extract issue fields
id: extract
run: |
echo ${{ toJSON(steps.parse.outputs.data) }} | \
jq --arg title "${{ steps.project_issue.outputs.title }}" \
--rawfile description "${{ runner.temp }}/description.md" \
--rawfile objective "${{ runner.temp }}/objective.md" \
--rawfile illustrations "${{ runner.temp }}/illustrations.md" \
--rawfile approach "${{ runner.temp }}/approach.md" \
--rawfile progress "${{ runner.temp }}/progress.md" \
--rawfile background "${{ runner.temp }}/background.md" '{
"title": $title,
"category": .category.text,
"presenter_location": .["presenter-location"].text,
"description": $description,
"objective": $objective,
"approach": $approach,
"progress": $progress,
"illustrations": $illustrations,
"background": $background,
"investigators": [.["key-investigators"].list[].text |
capture("(?<name>[^\\s]+(?:\\s[^\\s]+)*?)\\s*\\((?<affiliation>[^,]*)(?:,\\s*(?<country>[^)]*))?\\)") |
{name, affiliation: (.affiliation // ""), country: (.country // "")}],
}' > ${{ runner.temp }}/template-data.json
- name: Display template-data.json
run: |
cat ${{ runner.temp }}/template-data.json
- uses: actions/setup-python@v4.6.0
with:
python-version: "3.x"
- name: Install jinja2
run: |
python -m pip install jinja2
# Provide the cli interface
python -m pip install jinja2_cli
# Install the package providing the "to_yaml" and "regex_replace" filters.
python -m pip install jinja2-ansible-filters
- name: Generate Project README.md
run: |
jinja2 \
${{ steps.event_info.outputs.name }}/Projects/Template/README.md.j2 \
${{ runner.temp }}/template-data.json \
--format json \
-e "jinja2_ansible_filters.AnsibleCoreFiltersExtension" \
-o ${{ steps.event_info.outputs.name }}/Projects/${{ steps.project_directory.outputs.name }}/README.md
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v5
with:
token: ${{ steps.generate-token.outputs.token }}
commit-message: |
${{ steps.event_info.outputs.name }}: Add project ${{ steps.project_directory.outputs.name }}
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch: ${{ steps.event_info.outputs.name }}/${{ steps.project_directory.outputs.name }}
delete-branch: true
title: Add project "${{ steps.project_issue.outputs.title }}" to "${{ steps.event_info.outputs.name }}"
body: |
Fixes #${{ github.event.issue.number }}
labels: |
project
event:${{ steps.event_info.outputs.name }}
- name: Create or update comment ❌
if: ${{ failure() && steps.check_project_exists.outcome == 'success' }}
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.couc.outputs.comment-id }}
issue-number: ${{ github.event.issue.number }}
body: |
## Project Page Pull Request Creation
:x: **FAILED**: See ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
edit-mode: replace
- name: Create or update comment ✅
if: ${{ success() }}
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.couc.outputs.comment-id }}
issue-number: ${{ github.event.issue.number }}
body: |
## Project Page Pull Request Creation
:white_check_mark: **COMPLETED**: See ${{ steps.cpr.outputs.pull-request-url }}
edit-mode: replace
- name: Remove "project:create" label
if: ${{ always() }}
uses: actions/github-script@v6
with:
script: |
github.rest.issues.removeLabel({
issue_number: context.payload.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: ["project:create"]
})