From 2e5ea83021afaf553d3031bc42634d9438b4d97a Mon Sep 17 00:00:00 2001 From: Shashank R Date: Mon, 11 May 2026 15:22:43 +0530 Subject: [PATCH] feat: Add CSAT survey workflow and scripts --- .github/scripts/constant.js | 47 ++++++++++++++++++++++++++ .github/scripts/csat.js | 67 +++++++++++++++++++++++++++++++++++++ .github/workflows/csat.yml | 21 ++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 .github/scripts/constant.js create mode 100644 .github/scripts/csat.js create mode 100644 .github/workflows/csat.yml diff --git a/.github/scripts/constant.js b/.github/scripts/constant.js new file mode 100644 index 000000000..96e54f94d --- /dev/null +++ b/.github/scripts/constant.js @@ -0,0 +1,47 @@ +/* +Copyright 2026 Google LLC. All Rights Reserved. +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', + DOCUMENTATION: 'documentation', + GOOD_FIRST_ISSUE: 'good first issue', + ENHANCEMENT: 'enhancement', + QUESTION: 'question', + JAVA: 'java', + SAMPLE: 'sample', + TESTING: 'testing', + CONTRIB: 'contrib', + DEPENDENCIES: 'dependencies', + DUPLICATE: 'duplicate', + GITHUB: 'github', + NEEDS_UPDATE: 'needs update', + READY_TO_PULL: 'ready to pull' + }, + STATE: { CLOSED: 'closed' }, + }, + MODULE: { + CSAT: { + YES: 'Yes', + NO: 'No', + BASE_URL: 'https://docs.google.com/forms/d/e/1FAIpQLSeh96UhNq0-d4zdbKLj01Or56eqXom9iaw5sVquaB7Sno1SRg/viewform?usp=pp_url&', + SATISFACTION_PARAM: 'entry.885968193=', + ISSUEID_PARAM: '&entry.1737461264=', + 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 000000000..de99edcae --- /dev/null +++ b/.github/scripts/csat.js @@ -0,0 +1,67 @@ +/* +Copyright 2026 Google LLC. All Rights Reserved. +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_adkjava.yml 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; + const baseUrl = CONSTANT_VALUES.MODULE.CSAT.BASE_URL; + + // 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.DOCUMENTATION) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.GOOD_FIRST_ISSUE) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.ENHANCEMENT) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.QUESTION) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.JAVA) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.SAMPLE) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.TESTING) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.CONTRIB) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.DEPENDENCIES) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.DUPLICATE) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.GITHUB) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.NEEDS_UPDATE) || + label.name.includes(CONSTANT_VALUES.GLOBALS.LABELS.READY_TO_PULL)) { + + console.log(`label-${label.name}, posting CSAT survey for issue =${issue}`); + + 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 000000000..de619c201 --- /dev/null +++ b/.github/workflows/csat.yml @@ -0,0 +1,21 @@ +name: 'CSAT survey for ADK-Java' +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