Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 0 additions & 187 deletions .github/ISSUE_TEMPLATE/add-member.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
name: Update member profile 🧑‍🔬
name: Add or update member profile 🧑‍🔬
description: |
Use this form to update a lab member's profile on the website.
title: "[Update member]"
labels: ["automatic-update-member"]
Use this form to add a lab member to the website, or to update an existing profile.
title: "[Add/update member]"
labels: ["automatic-add-update-member"]
assignees:
- octocat
body:
- type: markdown
attributes:
value: |
*Only* fill out the required fields and the fields that you want to modify. Leave everything else blank.

When updating a profile, it will match the profile with the same full `name`. If multiple people have the same full name, it will match the first one encountered. In this case, you might want to to either make the change manually or move an older profile to the bottom (both require editing the YAML file).
Profiles are matched by full `name`:
- **The name already exists:** only the fields you fill in are updated; everything left blank stays as it is. To change just a photo, fill in Name and Avatar.
- **The name is new:** a new profile is created. Please fill in at least *Current Role Type*, *Current Role Title* and *Current Role Start Date*.

If multiple people have the same full name, the first one encountered is updated. In this case, either make the change manually or move an older profile to the bottom (both require editing the YAML file).

This form will automatically generate a PR that will be reviewed by the maintainers.

Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/process-issue-forms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,12 @@ jobs:
- name: Install Python requirements
run: pip install -r src/python/requirements.txt

# One form adds or updates a member depending on whether the name exists; the older
# add/update labels are still accepted for issues opened before the forms were merged.
- name: "Update _data/authors.yml with src/python/add_update_member.py"
if: github.event.label.name == 'automatic-add-member'
if: contains(fromJSON('["automatic-add-update-member", "automatic-add-member", "automatic-update-member"]'), github.event.label.name)
env:
ISSUE_BODY: ${{ github.event.issue.body }}
ACTION: Add member
run: python -m src.python.add_update_member

- name: "Update _data/authors.yml with src/python/add_update_member.py"
if: github.event.label.name == 'automatic-update-member'
env:
ISSUE_BODY: ${{ github.event.issue.body }}
ACTION: Update member
run: python -m src.python.add_update_member

- name: "Create post in _posts/papers with src/python/add_update_publication.py"
Expand Down
28 changes: 18 additions & 10 deletions src/python/add_update_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ def sort_by_lastname(authors: Dict) -> None:
authors.insert(0, user, desc)


def main(parsed: Dict, action: str, site_data_dir: str = "_data/", image_dir: str = "assets/images/bio") -> Dict:
def main(parsed: Dict, action: Optional[str] = None, site_data_dir: str = "_data/", image_dir: str = "assets/images/bio") -> Dict:
"""Add the member if the name is new, otherwise update only the fields filled in.

`action` is kept for backwards compatibility and no longer changes the behaviour.
"""
site_data_dir = Path(site_data_dir)
profile = format_parsed_content(parsed)

Expand All @@ -173,8 +177,18 @@ def main(parsed: Dict, action: str, site_data_dir: str = "_data/", image_dir: st

name_to_username = {authors[username]["name"]: username for username in authors}

if action == "Add member" and profile["name"] not in name_to_username:
if profile["name"] not in name_to_username:
# New member
role = profile.get("current_role") or {}
if "type" not in role or "title" not in role:
raise ValueError(
f'{profile["name"]} is not on the website yet: to add them, fill in at least '
'"Current Role Type" and "Current Role Title". To update an existing profile, '
'check that the name matches it exactly.'
)
profile.setdefault("auto_update_publications", False)
if "past_roles" in profile:
profile["past_roles"] = [profile["past_roles"]]
username = profile["name"]
if username in authors:
n = 2
Expand All @@ -183,12 +197,7 @@ def main(parsed: Dict, action: str, site_data_dir: str = "_data/", image_dir: st
username = k
authors[username] = profile
else:
# Update, or an "Add member" for someone already listed (e.g. a placeholder
# entry created by a maintainer): merge into the existing entry instead of
# creating a duplicate.
if profile["name"] not in name_to_username:
raise ValueError(f'{profile["name"]} not in authors')

# Existing member: merge in only the fields that were filled in
username = name_to_username[profile["name"]]
authors[username] = merge_profile_data(authors[username], profile)

Expand All @@ -215,6 +224,5 @@ def main(parsed: Dict, action: str, site_data_dir: str = "_data/", image_dir: st

if __name__ == "__main__":
issue_body = os.environ["ISSUE_BODY"]
action = os.environ["ACTION"]
parsed = parse_issue_body(issue_body)
main(parsed, action)
main(parsed)
Loading