Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add check for label before creating a new comment #2295

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions .github/workflows/check-manifests-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,27 @@ jobs:
with:
path: ./cache/pr/
key: ${{ env.PR_CACHE_KEY }}

create-main-manifests:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main

- name: Create manifests on main branch
run: |
make dry-run-control-plane
mkdir -p ./cache/main
mv ./dry-run/manifests.yaml ./cache/main/manifests.yaml

- name: Save main manifests in cache
uses: actions/cache@v3
with:
path: ./cache/main/
key: ${{ env.MAIN_CACHE_KEY }}

diff-manifests:
needs:
- create-pr-manifests
Expand All @@ -56,11 +60,13 @@ jobs:
with:
path: ./cache/pr/
key: ${{ env.PR_CACHE_KEY }}

- name: Restore main manifests from cache
uses: actions/cache@v3
with:
path: ./cache/main/
key: ${{ env.MAIN_CACHE_KEY }}

- name: Compare Manifests
id: compare-manifests
run: |
Expand All @@ -76,23 +82,39 @@ jobs:
echo "manifests_diff_detected=false" >> $GITHUB_OUTPUT
fi
exit 0

- name: Check if 'manifests-diff' Label Exists
id: check-manifests-label
uses: actions/github-script@v7
with:
script: |
const labelName = 'manifests-diff';
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
});
return labels.some(label => label.name === labelName);
result-encoding: string

- name: Add PR Comment if Manifest Differences Detected
if: steps.compare-manifests.outputs.manifests_diff_detected == 'true'
if: steps.compare-manifests.outputs.manifests_diff_detected == 'true' && steps.check-manifests-label.outputs.result != 'true'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: "❌ **Manifests created with 'make dry-run-control-plane' changed!** Please make sure to check if changes are needed in related repositories like management-plane-charts, runtime-watchter, etc.."
});
github.rest.issues.addLabels({
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ["manifests-diff"]
});

- name: Remove 'manifests-diff' Label if No Differences
if: steps.compare-manifests.outputs.manifests_diff_detected == 'false'
uses: actions/github-script@v7
Expand Down
23 changes: 20 additions & 3 deletions .github/workflows/check-pipeline-changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
pathsToCheck.some(path => file.filename === path || file.filename.startsWith(path + '/'))
);
core.setOutput('pipelineFiles', pipelineFiles.map(file => file.filename).join(','));

- name: Evaluate Pipeline Changes
id: eval-changes
run: |
Expand All @@ -45,23 +46,39 @@ jobs:
echo "✅ No pipeline-related changes detected."
echo "pipeline_changed=false" >> $GITHUB_OUTPUT
fi

- name: Check if 'pipeline-changed' Label Exists
id: check-pipeline-label
uses: actions/github-script@v7
with:
script: |
const labelName = 'pipeline-changed';
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
});
return labels.some(label => label.name === labelName);
result-encoding: string

- name: Add PR Comment & Label if Pipeline Changes Detected
if: steps.eval-changes.outputs.pipeline_changed == 'true'
if: steps.eval-changes.outputs.pipeline_changed == 'true' && steps.check-pipeline-label.outputs.result != 'true'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: "⚠️ **Pipeline-related file changes detected!** Please review if related updates (e.g. manifest generation or workflow adjustments) are required."
});
github.rest.issues.addLabels({
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ["pipeline-changed"]
});

- name: Remove 'pipeline-changed' Label if No Changes Detected
if: steps.eval-changes.outputs.pipeline_changed == 'false'
uses: actions/github-script@v7
Expand Down
Loading