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: Trigger warning for PRs likely requiring updates to management-plane-charts #2219

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e84d05f
Add GH workflow for detecting changes under config directory
medmes Jan 30, 2025
38d368a
Enhance the workflow for checking manifests changes as well.
medmes Jan 30, 2025
fe9a0bc
Test the workflow
medmes Jan 30, 2025
4bab3ad
Test the workflow- pull request target
medmes Jan 30, 2025
974263a
Add permission token.
medmes Jan 30, 2025
c124fd3
Change to pull_request_target
medmes Jan 30, 2025
ec56411
remove pull_request_target types
medmes Jan 30, 2025
57b6fa3
changed to PR to test on upstream
medmes Jan 30, 2025
fc47bf8
remove envs after testing
medmes Jan 30, 2025
baa1e06
Rename Job name
medmes Jan 30, 2025
c25021a
Changes on the CRD part.
medmes Jan 30, 2025
6d15458
Fail and comment
medmes Jan 30, 2025
3d01f0c
Revert "Fail and comment"
medmes Jan 30, 2025
1608059
Add fail condition on PR comment
medmes Jan 30, 2025
9742436
Add fail condition on PR comment
medmes Jan 30, 2025
d3c0d9e
Add fail condition on PR comment
medmes Jan 30, 2025
e1b8293
revert back and keep only Github Actions Workflow yaml file.
medmes Jan 30, 2025
45a38c8
revert back and keep only Github Actions Workflow yaml file.
medmes Jan 30, 2025
e60f1d9
Merge branch 'main' into trigger_warning_job_on_pr
medmes Jan 31, 2025
a836812
Draft Commit
medmes Jan 31, 2025
b0e45ae
Merge remote-tracking branch 'origin/trigger_warning_job_on_pr' into …
medmes Jan 31, 2025
a00d234
Merge branch 'main' into trigger_warning_job_on_pr
medmes Jan 31, 2025
dd2146d
Splitted jobs and added the possibility to remove label if the manife…
medmes Feb 3, 2025
f77d9ce
Merge branch 'main' into trigger_warning_job_on_pr
medmes Feb 3, 2025
6dc46d6
Merge branch 'main' of github.com:medmes/lifecycle-manager into trigg…
medmes Feb 3, 2025
4adb7df
Merge remote-tracking branch 'origin/trigger_warning_job_on_pr' into …
medmes Feb 3, 2025
4120aac
rename workflow name
medmes Feb 3, 2025
033c5af
changed into $GITHUB_OUTPUT instead of using env vars: $GITHUB_ENV
medmes Feb 3, 2025
e19d8bc
Refactoring
medmes Feb 3, 2025
d981bc5
Refactoring
medmes Feb 3, 2025
acf9f86
Refactoring
medmes Feb 3, 2025
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
70 changes: 70 additions & 0 deletions .github/workflows/check-configs-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: "Check Config Changes"

on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]

jobs:
check-configs-changes:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Install Dependencies
run: |
sudo apt update
sudo apt install -y make

- name: Get list of changed files
id: changed-files
uses: actions/github-script@v7
with:
script: |
const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
});
const configFiles = files.filter(file => file.filename.startsWith('config/'));
core.setOutput('configFiles', configFiles.map(file => file.filename).join(','));

- name: Evaluate Config Changes
id: eval-changes
run: |
echo "Changed config files:"
echo "${{ steps.changed-files.outputs.configFiles }}" | tr ',' '\n'
if [ "${{ steps.changed-files.outputs.configFiles }}" != "" ]; then
echo "⚠️ Config directory changes detected!"
echo "config_changed=true" >> $GITHUB_OUTPUT
else
echo "✅ No changes in config directory."
echo "config_changed=false" >> $GITHUB_OUTPUT
fi

- name: Add Warning if Config Files Changed
if: steps.eval-changes.outputs.config_changed == 'true'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: "⚠️ **Config folder changes detected!** Please review if manifest updates are necessary."
});

- name: Add PR Label for Config Changes
if: steps.eval-changes.outputs.config_changed == 'true'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ["configs-changed"]
});

128 changes: 128 additions & 0 deletions .github/workflows/check-manifests-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: "Check if Manifests are Up-to-Date"

env:
PR_CACHE_KEY: pr-manifests-${{ github.run_id }}-${{ github.run_attempt }}
MAIN_CACHE_KEY: main-manifests-${{ github.run_id }}-${{ github.run_attempt }}

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
create-pr-manifests:
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v4

- name: Run 'make manifests' on PR branch
run: |
make dry-run-control-plane
mkdir -p ./cache/pr
mv ./dry-run/manifests.yaml ./cache/pr/manifests.yaml

- name: Save PR manifests in cache
uses: actions/cache@v3
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: Run 'make 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
- create-main-manifests
runs-on: ubuntu-latest
steps:
- name: Restore PR manifests from cache
uses: actions/cache@v3
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: |
set +e
DIFF_OUTPUT=$(diff ./cache/pr/manifests.yaml ./cache/main/manifests.yaml)
EXIT_CODE=$?
if [[ $EXIT_CODE != 0 ]]; then
echo "❌ Detected diff in manifests!"
echo "$DIFF_OUTPUT"
echo "outdated_manifests=true" >> $GITHUB_OUTPUT
exit $EXIT_CODE
fi
echo "✅ No diff in manifests, all good."
echo "outdated_manifests=false" >> $GITHUB_OUTPUT

- name: Add PR Comment if Manifests Are Outdated
if: steps.compare-manifests.outputs.outdated_manifests == 'true'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: "❌ **Detected diff in manifests!** Run 'make manifests' and commit changes."
});
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ["outdated-manifests"]
});

- name: Remove 'outdated-manifests' Label if Fixed
if: steps.compare-manifests.outputs.outdated_manifests == 'false'
uses: actions/github-script@v7
with:
script: |
const labelName = 'outdated-manifests';
const { data: labels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
});
if (labels.some(label => label.name === labelName)) {
console.log(`Label "${labelName}" found, removing it.`);
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
name: labelName,
});
} else {
console.log(`Label "${labelName}" not found, skipping removal.`);
}

- name: Fail if Manifests Are Outdated
if: steps.compare-manifests.outputs.outdated_manifests == 'true'
run: |
echo "❌ Manifests are outdated! Run 'make manifests' and commit changes."
exit 1
Loading