From f3916ab96aea7a3ba86fe4da52183f73b0476fc5 Mon Sep 17 00:00:00 2001 From: Faith Kangai Date: Tue, 7 May 2024 20:34:36 +0300 Subject: [PATCH 1/2] Add github action to add new PR or issue to Project --- .../{projectbot.yml => project-auto-add.yml} | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) rename .github/workflows/{projectbot.yml => project-auto-add.yml} (66%) diff --git a/.github/workflows/projectbot.yml b/.github/workflows/project-auto-add.yml similarity index 66% rename from .github/workflows/projectbot.yml rename to .github/workflows/project-auto-add.yml index f697bf9b89c..018dce14acc 100644 --- a/.github/workflows/projectbot.yml +++ b/.github/workflows/project-auto-add.yml @@ -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 GraphSDKs 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 @@ -20,7 +27,7 @@ jobs: env: GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} ORGANIZATION: microsoftgraph - PROJECT_NUMBER: 28 + PROJECT_NUMBER: 55 run: | gh api graphql -f query=' query($org: String!, $number: Int!) { @@ -44,13 +51,13 @@ 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 + echo 'LANGUAGE_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Language") | .options[] | select(.name=="Csharp") |.id' project_data.json) >> $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!) { @@ -60,10 +67,10 @@ 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: | @@ -71,17 +78,17 @@ jobs: 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 From c1f32342525e5fe6ca8a6f2e161fd80f9c5b0e40 Mon Sep 17 00:00:00 2001 From: Faith Kangai Date: Wed, 8 May 2024 14:59:12 +0300 Subject: [PATCH 2/2] change target branch from main to dev --- .github/workflows/project-auto-add.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/project-auto-add.yml b/.github/workflows/project-auto-add.yml index 018dce14acc..0ea33e3bd54 100644 --- a/.github/workflows/project-auto-add.yml +++ b/.github/workflows/project-auto-add.yml @@ -9,7 +9,7 @@ on: types: - opened branches: - - 'main' + - 'dev' jobs: track_issue: