diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da9e657b..ea5ca159 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,6 +127,7 @@ jobs: SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }} SLACK_BOT_APP_ID: ${{ secrets.SLACK_BOT_APP_ID }} GH_APP_PRIVATE_KEY_FOR_GETSENTRY: ${{ secrets.GH_APP_PRIVATE_KEY_FOR_GETSENTRY}} + GH_APP_PRIVATE_KEY_FOR_CODECOV: ${{ secrets.GH_APP_PRIVATE_KEY_FOR_CODECOV}} GH_APP_IDENTIFIER: ${{ secrets.GH_APP_IDENTIFIER }} GH_WEBHOOK_SECRET: ${{ secrets.GH_WEBHOOK_SECRET }} SENTRY_WEBPACK_WEBHOOK_SECRET: ${{ secrets.SENTRY_WEBPACK_WEBHOOK_SECRET }} diff --git a/README.md b/README.md index fdac069d..eee7bd98 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ The events sent by the bot are defined under "Subscribe to bot events" in the "E - [A message was posted in a direct message channel](https://api.slack.com/events/message.im) - [A member's data has changed](https://api.slack.com/events/user_change). -### Github Sentry Webhooks +### GitHub Sentry Webhooks Under Sentry's [webhooks](https://github.com/organizations/getsentry/settings/hooks) there's webhooks to the production backend with the route "webhooks/github". @@ -167,11 +167,9 @@ You'll also need to create a private key for the service account (it should down - Leave the `privateKey` as-is, it's the name of an environment variable to pull from (the main `github-orgs.yml` holds public config and is checked into version control). - - In a terminal, log into the Github CLI using `gh auth login`. + - In a terminal, log into the GitHub CLI using `gh auth login`. - - Use [this](https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/using-the-api-to-manage-projects#finding-the-node-id-of-an-organization-project) GraphQL query to identify the node ID of the project you made earlier; set `project.nodeId` to match. - - - Use [this](https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/using-the-api-to-manage-projects#finding-the-node-id-of-a-field) GraphQL query to identify the IDs of the project fields you set up, and use those to populate `project.fieldIds`. + - Use the script at `bin/get-project-ids.sh $orgSlug $projectNumber` to determine the ids to set in `github-orgs.yml` for your project. 1. Follow the steps of the "Development & tests" section below to get the server running. @@ -248,7 +246,7 @@ yarn test This section only matters if you want to gather metrics from other projects than the ones we currently do. -Install [the Github application](https://github.com/organizations/getsentry/settings/apps/getsantry/installations) to relevant repos (you will need to contact IT for access to this app). This app is used for GitHub API access to the repos it is installed on. +Install [the GitHub application](https://github.com/organizations/getsentry/settings/apps/getsantry/installations) to relevant repos (you will need to contact IT for access to this app). This app is used for GitHub API access to the repos it is installed on. ### Deploying diff --git a/bin/deploy.sh b/bin/deploy.sh index ebd02c63..9d731980 100755 --- a/bin/deploy.sh +++ b/bin/deploy.sh @@ -5,6 +5,7 @@ IMAGE=gcr.io/${PROJECT}/product-eng-webhooks env_vars="ENV=production," env_vars="${env_vars}GH_APP_PRIVATE_KEY_FOR_GETSENTRY=${GH_APP_PRIVATE_KEY_FOR_GETSENTRY}," +env_vars="${env_vars}GH_APP_PRIVATE_KEY_FOR_CODECOV=${GH_APP_PRIVATE_KEY_FOR_CODECOV}," env_vars="${env_vars}GH_WEBHOOK_SECRET=${GH_WEBHOOK_SECRET}," env_vars="${env_vars}SLACK_SIGNING_SECRET=${SLACK_SIGNING_SECRET}," env_vars="${env_vars}SLACK_BOT_USER_ACCESS_TOKEN=${SLACK_BOT_USER_ACCESS_TOKEN}," diff --git a/bin/get-project-ids.sh b/bin/get-project-ids.sh new file mode 100755 index 00000000..d0c0dc4f --- /dev/null +++ b/bin/get-project-ids.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env zsh + +nodeId=$( + gh api graphql -f query=' + query{ + organization(login: "'$1'"){ + projectV2(number: '$2') { + id + } + } + }' \ + | jq -r '.data.organization.projectV2.id' +) + +fields=$( + gh api graphql -f query=' + query{ + node(id: "'$nodeId'") { + ... on ProjectV2 { + fields(first: 20) { + nodes { + ... on ProjectV2FieldCommon { + id + name + } + } + } + } + } + }' \ +) + +function id () { + echo "$fields" | jq -r '.data.node.fields.nodes[] | select(.name=="'"$1"'").id' +} + +echo " nodeId: '$nodeId'" +echo " fieldIds:" +echo " productArea: '"$(id 'Product Area')"'" +echo " status: '"$(id 'Status')"'" +echo " responseDue: '"$(id 'Response Due')"'" diff --git a/github-orgs.yml b/github-orgs.yml index 29ed8c45..dec8224d 100644 --- a/github-orgs.yml +++ b/github-orgs.yml @@ -47,3 +47,17 @@ getsentry: - 'sentry-android-gradle-plugin' - 'sentry-dotnet' - 'sentry-dart-plugin' +codecov: + appAuth: + appId: 343171 + privateKey: 'GH_APP_PRIVATE_KEY_FOR_CODECOV' + installationId: 40036835 + project: + nodeId: 'PVT_kwDOAH2Fnc4ARzsq' + fieldIds: + productArea: 'PVTSSF_lADOAH2Fnc4ARzsqzgLXyZg' + status: 'PVTSSF_lADOAH2Fnc4ARzsqzgLXyI4' + responseDue: 'PVTF_lADOAH2Fnc4ARzsqzgLXyhE' + repos: + withoutRouting: + - 'feedback'