CI: add workflow for branding name checks #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -------------------------------------------------------------------- | |
| # | |
| # Licensed to the Apache Software Foundation (ASF) under one or more | |
| # contributor license agreements. See the NOTICE file distributed | |
| # with this work for additional information regarding copyright | |
| # ownership. The ASF licenses this file to You 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. | |
| # | |
| # -------------------------------------------------------------------- | |
| # GitHub Actions Workflow: Brand Name Check for Changes | |
| # -------------------------------------------------------------------- | |
| # Description: | |
| # This GitHub Actions workflow checks pull requests (PRs) for deprecated | |
| # terms related to "Cloudberry" and "Greenplum". It ensures consistent | |
| # usage of updated branding throughout the project. | |
| # | |
| # Purpose: | |
| # - Identify outdated terms such as "Cloudberry Database" or "Greenplum". | |
| # - Automatically comment on the PR, suggesting replacements where needed. | |
| # - Encourage the use of "Apache Cloudberry" or "Cloudberry" as standards. | |
| # | |
| # How it works: | |
| # - Triggers when a PR is opened, edited, or synchronized with its branch. | |
| # - Scans only the changes (diffs) in the PR, focusing on modified content. | |
| # - Posts a comment if deprecated terms are detected in the changes. | |
| # | |
| # Note: This GitHub Actions is not a required option for merging one | |
| # Pull Request, just as one reference for the brand check. | |
| name: Brand Name Checks for Diffs | |
| on: | |
| pull_request: | |
| types: [opened, edited, synchronize] | |
| jobs: | |
| check-brand-name: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Check for Old Names in PR Diffs | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| const prNumber = context.payload.pull_request.number; | |
| const owner = context.repo.owner; | |
| const repo = context.repo.repo; | |
| // List of deprecated terms to check in PR changes | |
| const deprecatedTerms = [ | |
| "Cloudberry Database", | |
| "CloudberryDB", | |
| "Cloudberry DB", | |
| "Greenplum Database", | |
| "Greenplum", | |
| "GPDB" | |
| ]; | |
| // Fetch the list of changed files in the PR | |
| const { data: files } = await github.rest.pulls.listFiles({ | |
| owner, | |
| repo, | |
| pull_number: prNumber, | |
| }); | |
| // Check diffs for deprecated terms | |
| const foundTerms = new Set(); | |
| for (const file of files) { | |
| if (file.patch) { | |
| for (const term of deprecatedTerms) { | |
| if (file.patch.includes(term)) { | |
| foundTerms.add(term); | |
| } | |
| } | |
| } | |
| } | |
| // Post a comment on the PR if any terms are found | |
| if (foundTerms.size > 0) { | |
| const commentBody = ` | |
| **Attention:** The following old brand terms were found | |
| in your changes: | |
| ${[...foundTerms].map(term => `- **${term}**`).join('\n')} | |
| Please consider replacing them with "Apache Cloudberry" or | |
| "Cloudberry" where appropriate. Thank you for ensuring | |
| consistency in our branding! 🙏 | |
| > [!NOTE] | |
| > This is not a required check for merging this PR, just for your reference. | |
| `; | |
| await github.rest.issues.createComment({ | |
| owner, | |
| repo, | |
| issue_number: prNumber, | |
| body: commentBody, | |
| }); | |
| } |