--- /dev/null
+name: Check ceph config changes
+on:
+ pull_request_target:
+ types:
+ - opened
+ - synchronize
+ - edited
+ - reopened
+
+# The following permissions are needed to write a comment to repo
+permissions:
+ issues: write
+ contents: read
+ pull-requests: write
+
+jobs:
+ pull_request:
+ runs-on: ubuntu-latest
+ steps:
+ - name: checkout ceph.git
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
+ with:
+ path: ceph
+ sparse-checkout: |
+ src/script
+ src/common/options
+ .github/workflows
+
+ - name: Setup Python
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #v5.6.0
+ with:
+ python-version: '3.13'
+
+ - name: Install python packages
+ run: |
+ pip3 install -r ./src/script/config-diff/requirements.txt
+ working-directory: ceph
+
+ - name: execute config diff tool
+ id: diff_tool
+ env:
+ REF_REPO: ${{ github.event.pull_request.base.repo.clone_url }}
+ REF_BRANCH: ${{ github.event.pull_request.base.ref }}
+ REMOTE_REPO: ${{ github.event.pull_request.head.repo.clone_url }}
+ REMOTE_BRANCH: ${{ github.event.pull_request.head.ref }}
+ run: |
+ {
+ echo 'DIFF_JSON<<EOF'
+ python3 ./src/script/config-diff/config_diff.py diff-branch-remote-repo --ref-branch $REF_BRANCH --remote-repo $REMOTE_REPO --cmp-branch $REMOTE_BRANCH --format=posix-diff --skip-clone
+ echo EOF
+ } >> "$GITHUB_OUTPUT"
+ working-directory: ceph
+
+ - name: Post output as a comment
+ uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea #v7.0.1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ DIFF_JSON_OUTPUT: ${{ steps.diff_tool.outputs.DIFF_JSON }}
+ with:
+ script: |
+ const configDiff = process.env.DIFF_JSON_OUTPUT;
+ const postComment = require('./ceph/.github/workflows/scripts/config-diff-post-comment.js');
+ postComment({ github, context, core, configDiff });
\ No newline at end of file
--- /dev/null
+module.exports = async ({ github, context, core, configDiff }) => {
+ try {
+ // Do not create comment if there are no configuration changes
+ if (!configDiff) {
+ console.log("No changes detected. Skipping comment creation.");
+ return;
+ }
+
+ const commentBody = `
+### Config Diff Tool Output
+
+\`\`\`diff
+
+${configDiff}
+
+\`\`\`
+
+
+The above configuration changes are found in the PR. Please update the relevant release documentation if necessary.
+ `;
+
+ core.summary.addRaw(commentBody);
+ await core.summary.write()
+
+ const { owner, repo } = context.repo;
+ const issueNumber = context.payload.pull_request.number;
+
+ // List all files in the pull request
+ core.info("Fetching list of files changed in the pull request...");
+ const files = await github.paginate(
+ github.rest.pulls.listFiles,
+ {
+ owner,
+ repo,
+ pull_number: issueNumber,
+ per_page: 100,
+ }
+ );
+
+ // Annotate YAML files
+ files.forEach(file => {
+ // Only annotate the `yaml.in` files present in `src/common/options` folder
+ if (file.filename.endsWith(".yaml.in") && file.filename.startsWith("src/common/options/")) {
+ core.info(`Annotating file: ${file.filename}`);
+ core.notice(
+ `Configuration changes detected in ${file.filename}. Please update the relevant release documentation if necessary.`,
+ {
+ title: "Configuration Change Detected",
+ file: file.filename,
+ startLine: 1,
+ endLine: 1,
+ }
+ );
+ }
+ });
+
+
+ // List all the comments
+ const comments = await github.paginate(
+ github.rest.issues.listComments, {
+ owner,
+ repo,
+ issue_number: issueNumber,
+ per_page: 100,
+ }
+ );
+
+ const existingComment = comments.find(comment => comment.body.includes("### Config Diff Tool Output"));
+
+ if (existingComment) {
+ core.info("A config diff comment already exists, deleting it...");
+ } else {
+ core.info("Creating a new config diff comment...");
+ // Create a new comment
+ await github.rest.issues.createComment({
+ issue_number: issueNumber,
+ owner,
+ repo,
+ body: commentBody,
+ });
+
+ }
+
+ // Set the status as FAILED if any configuration changes are detected
+ core.setFailed("Configuration Changes Detected, Update release documents - if necessary");
+ } catch (error) {
+ core.setFailed(error.message);
+ }
+}
\ No newline at end of file