Skip to content

Commit

Permalink
Test if GitHub Action add_pr_to_smackore_board works again (#806)
Browse files Browse the repository at this point in the history
Co-authored-by: Feliks Pobiedziński <38541925+FelonEkonom@users.noreply.github.com>
  • Loading branch information
bartkrak and FelonEkonom committed May 28, 2024
1 parent eae44ae commit ca34336
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 26 deletions.
30 changes: 15 additions & 15 deletions .github/actions/add_pr_to_smackore_board/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Add PR to Smackore board, if author is from community'
description: '(disabled due to github-side bug) Adds PR to "New issues by community" column in Smackore project board, if PR author is from outside Membrane Team.'
description: 'Adds PR to "New issues by community" column in Smackore project board, if PR author is from outside Membrane Team.'
inputs:
GITHUB_TOKEN:
description: 'GitHub token'
Expand All @@ -19,23 +19,23 @@ runs:
repository: membraneframework/membrane_core
- name: Maybe add PR to board and set ticket status
run: |
# currently this causes github action crash, more info here: https://github.com/membraneframework/membrane_core/issues/749
# export PROJECT_NUMBER=19
# export PROJECT_ID=PVT_kwDOAYE_z84AWEIB
# export STATUS_FIELD_ID=PVTSSF_lADOAYE_z84AWEIBzgOGd1k
# export TARGET_COLUMN_ID=e6b1ee10
# currently this may cause github action crash, more info here: https://github.com/membraneframework/membrane_core/issues/749
export PROJECT_NUMBER=19
export PROJECT_ID=PVT_kwDOAYE_z84AWEIB
export STATUS_FIELD_ID=PVTSSF_lADOAYE_z84AWEIBzgOGd1k
export TARGET_COLUMN_ID=e6b1ee10
# export AUTHOR_ORIGIN=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /orgs/membraneframework/teams/membraneteam/members | python scripts/python/get_author_origin.py $AUTHOR_LOGIN)
export AUTHOR_ORIGIN=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /orgs/membraneframework/teams/membraneteam/members | python scripts/python/get_author_origin.py $AUTHOR_LOGIN)
# if [ "$AUTHOR_ORIGIN" == "COMMUNITY" ]
# then
# gh pr edit "$PR_URL" --add-project Smackore
# sleep 10
if [ "$AUTHOR_ORIGIN" == "COMMUNITY" ]
then
gh pr edit "$PR_URL" --add-project Smackore
sleep 10
# export TICKET_ID=$(gh project item-list $PROJECT_NUMBER --owner membraneframework --format json --limit 10000000 | python scripts/python/get_ticket_id.py "$PR_URL")
# gh project item-edit --id $TICKET_ID --field-id $STATUS_FIELD_ID --project-id $PROJECT_ID --single-select-option-id $TARGET_COLUMN_ID
# fi
export TICKET_ID=$(gh project item-list $PROJECT_NUMBER --owner membraneframework --format json --limit 10000000 | python scripts/python/get_ticket_id.py "$PR_URL")
gh project item-edit --id $TICKET_ID --field-id $STATUS_FIELD_ID --project-id $PROJECT_ID --single-select-option-id $TARGET_COLUMN_ID
fi
env:
GH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions scripts/python/get_author_origin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@

print("COMMUNITY")
except:
print("An exception occurred, provided JSON:")
print(membrane_team)
print("provided PR_AUTHOR:", pr_author)
print("An exception occurred in get_author_origin.py, provided JSON: ", membrane_team)
print("Provided PR_AUTHOR: ", pr_author)
sys.exit(1)
23 changes: 15 additions & 8 deletions scripts/python/get_ticket_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
full_json = json.load(sys.stdin)
pr_url = sys.argv[1]

try:
project_items = full_json["items"]
[id] = [item["id"] for item in project_items if ("url" in item["content"] and item["content"]["url"] == pr_url)]
print(id)
except:
print("An exception occurred, provided JSON:")
print(full_json)
print("provided PR_URL:", pr_url)
project_items = full_json["items"]

item_id = None
for item in project_items:
if "content" in item and "url" in item["content"]:
if item["content"]["url"] == pr_url:
item_id = item["id"]
break

if item_id == None:
print("Error occurred in get_ticket.py: ID of ticket related to PR", pr_url, "not found in the provided JSON")
print("Provided JSON:", full_json)
sys.exit(1)
else:
print(item_id)

0 comments on commit ca34336

Please sign in to comment.