Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add action putting community PRs on the board, refactor old actions #662

Merged
merged 2 commits into from
Oct 31, 2023
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
3 changes: 1 addition & 2 deletions .formatter.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ locals_without_parens =

[
inputs: [
"{lib,test,config,benchmark}/**/*.{ex,exs}",
"scripts/*.exs",
"{lib,test,config,benchmark,scripts}/**/*.{ex,exs}",
"*.exs"
],
locals_without_parens: locals_without_parens,
Expand Down
42 changes: 42 additions & 0 deletions .github/actions/add_pr_to_smackore_board/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: 'Add PR to Smackore board, if author is from community'
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'
required: true
AUTHOR_LOGIN:
description: 'PR author login'
required: true
PR_URL:
description: 'PR URL'
required: true
runs:
using: 'composite'
steps:
- name: Checkout membrane_core code
uses: actions/checkout@v3
with:
repository: membraneframework/membrane_core
- name: Maybe add PR to board and set ticket status
run: |
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=$(curl --request GET --url "https://api.github.com/orgs/membraneframework/members" --header "Authorization: Bearer $GH_TOKEN" -s | python scripts/python/get_author_origin.py $AUTHOR_LOGIN)

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

env:
GH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
AUTHOR_LOGIN: ${{ inputs.AUTHOR_LOGIN }}
PR_URL: ${{ inputs.PR_URL }}
shell: bash
2 changes: 1 addition & 1 deletion .github/actions/close_issue/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ runs:
gh issue edit $ISSUE_URL --add-project "Smackore"
sleep 10

export TICKET_ID=$(gh project item-list $PROJECT_NUMBER --owner membraneframework --format json --limit 10000000 | elixir ./scripts/get_ticket_id.exs "$ISSUE_URL" | awk '/TICKET_ID/{print $2}')
export TICKET_ID=$(gh project item-list $PROJECT_NUMBER --owner membraneframework --format json --limit 10000000 | python ./scripts/python/get_ticket_id.py "$ISSUE_URL")
gh issue close $ISSUE_URL --comment "$ISSUE_CLOSE_COMMENT" --reason "not planned"
sleep 10

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-packages-list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
elixir scripts/update_packages_list.exs
elixir scripts/elixir/update_packages_list.exs
git config user.name 'Membrane Bot'
git config user.email '[email protected]'
git checkout -B auto-update-packages-list
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ If you have any questions regarding Membrane Framework or need consulting, feel
## All packages

<!-- packages-list-start -->
<!-- Generated code, do not edit. See `update_packages_list.exs`. -->
<!-- Generated code, do not edit. See `scripts/elixir/update_packages_list.exs`. -->


### General
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ packages_md =
packages_md =
"""
<!-- packages-list-start -->
<!-- Generated code, do not edit. See `update_packages_list.exs`. -->
<!-- Generated code, do not edit. See `scripts/elixir/update_packages_list.exs`. -->

#{packages_md}

Expand Down
23 changes: 0 additions & 23 deletions scripts/get_ticket_id.exs

This file was deleted.

12 changes: 12 additions & 0 deletions scripts/python/get_author_origin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import sys, json;

membrane_team = json.load(sys.stdin)
pr_author = sys.argv[1]

for person in membrane_team:
if person["login"] == pr_author:
print("MEMBRANE")
sys.exit(0)

print("COMMUNITY")

6 changes: 6 additions & 0 deletions scripts/python/get_ticket_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys, json;

project_items = json.load(sys.stdin)["items"]
pr_url = sys.argv[1]
[id] = [item["id"] for item in project_items if item["content"]["url"] == pr_url]
print(id)