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

chore: Add github action to add new PR or Issue to project kiota #4616

Merged
merged 1 commit into from
May 7, 2024
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
5 changes: 3 additions & 2 deletions .github/ISSUE_TEMPLATE/01-kiota-bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ body:
- type: dropdown
id: language
attributes:
label: Client Library/SDK Language
label: Client library/SDK language
description: If Client SDK, what's the language in use?
multiple: false
options:
- C#
- Csharp
- CLI
- Go
- Java
Expand All @@ -45,6 +45,7 @@ body:
- Python
- Ruby
- TypeScript
- Swift
validations:
required: false
- type: textarea
Expand Down
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/02-kiota-feature-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ body:
description: Is feature request related to any client library/SDK language?
multiple: false
options:
- C#
- Csharp
- CLI
- Go
- Java
Expand All @@ -30,6 +30,7 @@ body:
- Python
- Ruby
- TypeScript
- Swift
validations:
required: false
- type: textarea
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
# This workflow is used to add new issues to GitHub Projects (Beta)
# This workflow is used to add new issues to GitHub Kiota Project

name: Add PR to project
name: Add Issue or PR to project
on:
issues:
types:
- opened
pull_request:
types:
- opened
branches:
- 'main'

jobs:
track_issue:
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Generate token
Expand All @@ -16,11 +23,26 @@ jobs:
app_id: ${{ secrets.GRAPHBOT_APP_ID }}
private_key: ${{ secrets.GRAPHBOT_APP_PEM }}

- name: Check if issue has language specified
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
language=$(awk '/SDK language/{flag=1;next} /Describe/{flag=0} flag' <<< "${{github.event.issue.body}}" | tr -d '[:space:]')
allowedList="PHP Python Go TypeScript Csharp Java PowerShell CLI Ruby Swift"
if [[ $allowedList =~ (^|[[:space:]])$language($|[[:space:]]) ]]; then
echo "$language is in allowed list";
echo 'LANGUAGE='$language >> $GITHUB_ENV;
echo 'SELECTED_LANGUAGE='$language >> $GITHUB_ENV;
else
echo "$language is not allowed";
echo 'SELECTED_LANGUAGE=Multiple Languages' >> $GITHUB_ENV;
fi

- name: Get project data
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
ORGANIZATION: microsoftgraph
PROJECT_NUMBER: 28
ORGANIZATION: microsoft
PROJECT_NUMBER: 220
run: |
gh api graphql -f query='
query($org: String!, $number: Int!) {
Expand All @@ -44,13 +66,14 @@ jobs:
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json

echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
echo 'TRIAGE_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="Needs Triage 🔍") |.id' project_data.json) >> $GITHUB_ENV
echo 'LANGUAGE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Language") | .id' project_data.json) >> $GITHUB_ENV
LANGUAGE_OPTION_ID=$(jq --arg lang "$SELECTED_LANGUAGE" '.data.organization.projectV2.fields.nodes[] | select(.name== "Language") | .options[] | select(.name==$lang) | .id' project_data.json)
echo "LANGUAGE_OPTION_ID=$LANGUAGE_OPTION_ID" >> $GITHUB_ENV

- name: Add Issue to project
- name: Add Issue or PR to project
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
ISSUE_ID: ${{ github.event.issue.node_id }}
ISSUE_ID: ${{ github.event_name == 'issues' && github.event.issue.node_id || github.event.pull_request.node_id }}
run: |
item_id="$( gh api graphql -f query='
mutation($project:ID!, $issue:ID!) {
Expand All @@ -60,28 +83,28 @@ jobs:
}
}
}' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.addProjectV2ItemById.item.id')"

echo 'ITEM_ID='$item_id >> $GITHUB_ENV

- name: Set Triage
- name: Set Language
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
gh api graphql -f query='
mutation (
$project: ID!
$item: ID!
$status_field: ID!
$status_value: String!
$language_field: ID!
$language_value: String!
) {
set_status: updateProjectV2ItemFieldValue(input: {
projectId: $project
itemId: $item
fieldId: $status_field
value: {singleSelectOptionId: $status_value}
fieldId: $language_field
value: {singleSelectOptionId: $language_value}
}) {
projectV2Item {
id
}
}
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f status_field=$STATUS_FIELD_ID -f status_value=${{ env.TRIAGE_OPTION_ID }} --silent
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f language_field=$LANGUAGE_FIELD_ID -f language_value=${{ env.LANGUAGE_OPTION_ID }} --silent
Loading