github.com/prebid/prebid-server/v2@v2.18.0/.github/workflows/issue_prioritization.yml (about)

     1  name: Issue tracking
     2  on:
     3    issues:
     4      types:
     5        - opened
     6        - labeled
     7  jobs:
     8    track_issue:
     9      runs-on: ubuntu-latest
    10      steps:
    11        - name: Generate token
    12          id: generate_token
    13          uses: tibdex/github-app-token@v2.1.0
    14          with:
    15            app_id: ${{ secrets.PBS_PROJECT_APP_ID }}
    16            private_key: ${{ secrets.PBS_PROJECT_APP_PEM }}
    17  
    18        - name: Get project data
    19          env:
    20            GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
    21            ORGANIZATION: prebid
    22            DATE_FIELD: Created on
    23            PROJECT_NUMBER: 4
    24          run: |
    25            gh api graphql -f query='
    26              query($org: String!, $number: Int!) {
    27                organization(login: $org){
    28                  projectV2(number: $number) {
    29                    id
    30                    fields(first:100) {
    31                      nodes {
    32                        ... on ProjectV2Field {
    33                          id
    34                          name
    35                        }
    36                        ... on ProjectV2SingleSelectField {
    37                          id
    38                          name
    39                          options {
    40                            id
    41                            name
    42                          }
    43                        }
    44                      }
    45                    }
    46                  }
    47                }
    48              }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
    49  
    50            echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
    51            echo 'DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name=="'"$DATE_FIELD"'") | .id' project_data.json) >> $GITHUB_ENV
    52  
    53        - name: Add issue to project
    54          env:
    55            GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
    56            ISSUE_ID: ${{ github.event.issue.node_id }}
    57          run: |
    58            gh api graphql -f query='
    59              mutation($project:ID!, $issue:ID!) {
    60                addProjectV2ItemById(input: {projectId: $project, contentId: $issue}) {
    61                  item {
    62                    id
    63                    content {
    64                       ... on Issue {
    65                          createdAt
    66                       }
    67                       ... on PullRequest {
    68                          createdAt
    69                       }                     
    70                    }
    71                  }
    72                }
    73              }' -f project=$PROJECT_ID -f issue=$ISSUE_ID > issue_data.json
    74            
    75            echo 'ITEM_ID='$(jq '.data.addProjectV2ItemById.item.id' issue_data.json) >> $GITHUB_ENV
    76            echo 'ITEM_CREATION_DATE='$(jq '.data.addProjectV2ItemById.item.content.createdAt' issue_data.json | cut -c 2-11) >> $GITHUB_ENV
    77  
    78        - name: Set fields
    79          env:
    80            GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
    81          run: |
    82            gh api graphql -f query='
    83              mutation (
    84                $project: ID!
    85                $item: ID!
    86                $date_field: ID!
    87                $date_value: Date!
    88              ) {
    89                set_creation_date: updateProjectV2ItemFieldValue(input: {
    90                  projectId: $project
    91                  itemId: $item
    92                  fieldId: $date_field
    93                  value: {
    94                    date: $date_value
    95                  }
    96                }) {
    97                  projectV2Item {
    98                    id
    99                  }
   100                }
   101              }' -f project=$PROJECT_ID -f item=$ITEM_ID -f date_field=$DATE_FIELD_ID -f date_value=$ITEM_CREATION_DATE --silent