Open5

GitHub Project の Iteration を自動更新したい

ykwsykws

gh を利用した場合 iteration-id さえわかれば更新できそう
ただ iteration-id を知る方法が不明で、 GraphQL なら Iteration 一覧の ID がわかるのではと思った

gh project item-edit --id "PVTI_lAHOAFgM8M4AeGOozgNUvTw" --field-id "PVTIF_lAHOAFgM8M4AeGOozgT0b4Y" --project-id "PVT_kwHOAFgM8M4AeGOo" --iteration-id "@current"
ykwsykws

GraphQL で Iteration 一覧の ID が取得できた

query {
  user(login:"ykws") {
    projectV2(number:8) {
      fields(first: 100) {
        nodes {
          ... on ProjectV2IterationField {
            id
            name
            configuration {
              iterations {
                id
                __typename
                title
                startDate
                duration
              }
            }
          }
        }
      }
    }
  }
}
{
  "data": {
    "user": {
      "projectV2": {
        "fields": {
          "nodes": [
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {},
            {
              "id": "PVTIF_lAHOAFgM8M4AeGOozgT0b4Y",
              "name": "Iteration",
              "configuration": {
                "iterations": [
                  {
                    "id": "381c7c80",
                    "__typename": "ProjectV2IterationFieldIteration",
                    "title": "Iteration 1",
                    "startDate": "2024-03-08",
                    "duration": 14
                  },
                  {
                    "id": "54cf5c95",
                    "__typename": "ProjectV2IterationFieldIteration",
                    "title": "Iteration 2",
                    "startDate": "2024-03-22",
                    "duration": 14
                  },
                  {
                    "id": "d2c335bc",
                    "__typename": "ProjectV2IterationFieldIteration",
                    "title": "Iteration 3",
                    "startDate": "2024-04-05",
                    "duration": 14
                  },
                  {
                    "id": "b6a8f1bb",
                    "__typename": "ProjectV2IterationFieldIteration",
                    "title": "Iteration 4",
                    "startDate": "2024-04-19",
                    "duration": 14
                  },
                  {
                    "id": "955c1297",
                    "__typename": "ProjectV2IterationFieldIteration",
                    "title": "Iteration 5",
                    "startDate": "2024-05-03",
                    "duration": 14
                  }
                ]
              }
            }
          ]
        }
      }
    }
  }
}
ykwsykws

Iteration を更新できた

gh project item-edit --id "PVTI_lAHOAFgM8M4AeGOozgNUvTw" --field-id "PVTIF_lAHOAFgM8M4AeGOozgT0b4Y" --project-id "PVT_kwHOAFgM8M4AeGOo" --iteration-id "381c7c80"