diff --git a/.github/scripts/constant.js b/.github/scripts/constant.js new file mode 100644 index 0000000000..142efb7838 --- /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; diff --git a/.github/scripts/csat.js b/.github/scripts/csat.js new file mode 100644 index 0000000000..0c0168f861 --- /dev/null +++ b/.github/scripts/csat.js @@ -0,0 +1,59 @@ +/* +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 csat.yml workflow file to post survey link + * in closed issues. + * @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; + + // Check if any label matches (case-insensitive) the supported CSAT labels. + const supportedLabels = Object.values(CONSTANT_VALUES.GLOBALS.LABELS); + const hasMatchingLabel = context.payload.issue.labels.some(label => { + const name = label.name.toLowerCase(); + return supportedLabels.some(supportedLabel => name.includes(supportedLabel)); + }); + + if (hasMatchingLabel) { + console.log(`Posting CSAT survey for issue =${issue}`); + const 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'; + const 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..24569d6646 --- /dev/null +++ b/.github/workflows/csat.yml @@ -0,0 +1,20 @@ +name: 'CSAT survey for ADK-Python' +on: + issues: + types: + - closed + +permissions: + contents: read + issues: 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})