diff --git a/.github/scripts/constant.js b/.github/scripts/constant.js new file mode 100644 index 0000000000..588a9c9337 --- /dev/null +++ b/.github/scripts/constant.js @@ -0,0 +1,52 @@ +/* +Copyright 2026 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +let CONSTANT_VALUES = { + GLOBALS: { + LABELS: { + BUG: 'bug', + CORE: 'core', + TOOLS: 'tools', + SERVICES: 'services', + MODELS: 'models', + MCP: 'mcp', + AUTH: 'auth', + LIVE: 'live', + DOCUMENTATION: 'documentation', + GOOD_FIRST_ISSUE: 'good first issue', + AGENT_ENGINE: 'agent engine', + BQ: 'bq', + EVAL: 'eval', + TRACING: 'tracing', + WEB: 'web', + WORKFLOW: 'workflow' + }, + STATE: { CLOSED: 'closed' } + }, + MODULE: { + CSAT: { + YES: 'Yes', + NO: 'No', + BASE_URL: + 'https://docs.google.com/forms/d/e/1FAIpQLScgyeKPxUlq4kgNuI7g9_iXkQKlzT6ZvGA656x5HpbUpYjOsg/viewform?usp=pp_url&', + SATISFACTION_PARAM: 'entry.817493361=', + ISSUEID_PARAM: '&entry.1977942008=', + MSG: 'Are you satisfied with the resolution of your issue?', + } + } + +}; +module.exports = CONSTANT_VALUES; \ No newline at end of file diff --git a/.github/scripts/csat.js b/.github/scripts/csat.js new file mode 100644 index 0000000000..6bea90e0f6 --- /dev/null +++ b/.github/scripts/csat.js @@ -0,0 +1,69 @@ +/* +Copyright 2026 Google LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +const CONSTANT_VALUES = require('./constant'); + +/** + * Invoked from stale_csat.js and csat.yaml file to post survey link + * in closed issue. + * @param {!Object.} github contains pre defined functions. + * context Information about the workflow run. + * @return {null} + */ +module.exports = async ({ github, context }) => { + const issue = context.payload.issue.html_url; + let baseUrl = ''; + // Loop over all ths label present in issue and check if specific label is + // present for survey link. + for (const label of context.payload.issue.labels) { + if (label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.BUG) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.CORE) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.TOOLS) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.SERVICES) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.MODELS) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.MCP) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.AUTH) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.LIVE) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.DOCUMENTATION) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.GOOD_FIRST_ISSUE) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.AGENT_ENGINE) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.BQ) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.EVAL) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.TRACING) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.WEB) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.WORKFLOW)) { + console.log( + `label-${label.name}, posting CSAT survey for issue =${issue}`); + baseUrl = CONSTANT_VALUES.MODULE.CSAT.BASE_URL; + + const yesCsat = ` ${CONSTANT_VALUES.MODULE.CSAT.YES}`; + + const noCsat = ` ${CONSTANT_VALUES.MODULE.CSAT.NO}`; + const comment = CONSTANT_VALUES.MODULE.CSAT.MSG + '\n' + yesCsat + '\n' + + noCsat + '\n'; + let issueNumber = context.issue.number ?? context.payload.issue.number; + await github.rest.issues.createComment({ + issue_number: issueNumber, + owner: context.repo.owner, + repo: context.repo.repo, + body: comment + }); + } + } +}; diff --git a/.github/workflows/csat.yml b/.github/workflows/csat.yml new file mode 100644 index 0000000000..5da6ff909f --- /dev/null +++ b/.github/workflows/csat.yml @@ -0,0 +1,21 @@ +name: 'CSAT survey for ADK-Python' +on: + issues: + types: + - closed + +permissions: + contents: read + issues: write + pull-requests: write + +jobs: + welcome: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/github-script@v6 + with: + script: | + const script = require('./.github/scripts/csat.js') + script({github, context}) \ No newline at end of file