feat: Trigger warning job on pr test #10
Workflow file for this run
This file contains 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
name: "Check Config and Manifests changes" | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
check-configs-manifests-changes: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 # Needed for diff comparison | |
- 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 | |
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_ENV | |
else | |
echo "✅ No changes in config directory." | |
echo "config_changed=false" >> $GITHUB_ENV | |
fi | |
- name: Run `make manifests` | |
run: make manifests | |
- name: Compare Generated Manifests with `main` | |
id: check-manifests | |
run: | | |
git diff --exit-code config/ || echo "outdated_manifests=true" >> $GITHUB_ENV | |
continue-on-error: true | |
- name: Add Warning if Config Files Changed | |
if: env.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: env.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"] | |
}); | |
- name: Fail if Manifests Are Outdated | |
if: env.outdated_manifests == 'true' | |
run: | | |
echo "❌ Manifests are outdated! Run 'make manifests' and commit changes." | |
exit 1 | |
- name: Add PR Comment if Manifests Are Outdated | |
if: failure() && env.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: "❌ **Manifests are outdated!** Please run `make manifests` and commit the changes." | |
labels: ["manifests-outdated"] | |
}); |